I have a webapp (call it myapp.com) that allows users to upload files. The webapp will be deployed on Amazon EC2 instance. I would like to serve these files back out to the webapp consumers via an s3 bucket based domain (i.e. uploads.myapp.com).
When the user uploads the files, I can easily drop them in into a folder called "site_up...
Possible Duplicate:
Is there a way to list all the available drive letters in python?
What's the way to retrieve currently mounted drive list in Windows incl. Thumb drives, and mapped networks.
i currently do
drives=[]
for c in string.lowercase:
if os.path.isdir(c+':'):
drives.append(c+':')
which lo...
How do I find out which class I am initialising a decorator in? It makes sense that I wouldn't be able to find this out as the decorator is not yet bound to the class, but is there a way of getting round this?
class A(object):
def dec(f):
# I am in class 'A'
def func(cls):
f(cls)
return func
@dec...
Specifically, are there any libraries that do not use sockets?
I will be running this code in Google App Engine, which does not allow the use of sockets.
Google app engine does allow the use of urllib2 to make web requests.
I've been trying to get mechanize to work, since that what I've used before, but if there's something easier, I'd...
Hello all,
I have been trying to track down weird problems with my mod_wsgi/Python web application. I have the application handler which creates an object and calls a method:
def my_method(self, file):
self.sapi.write("In my method for %d time"%self.mmcount)
self.mmcount += 1
# ... open file (absolute path to file), extrac...
I have an SqlAlchemy table like so:
table = sql.Table('treeItems', META,
sql.Column('id', sql.Integer(), primary_key=True),
sql.Column('type', sql.String, nullable=False),
sql.Column('parentId', sql.Integer, sql.ForeignKey('treeItems.id')),
sql.Column('lineage', PGArray(sql.Integer)),
sql.Column('depth', sql.Integer)...
I haven't found any information on that topic and its homepage doesn't mention it.
...
I'm writing a macro generator/ keyboard remapper in python, for xubuntu.
I've figured out how to intercept and record keystrokes, and send keystrokes I want to record, but I haven't figured out how to block keystrokes. I need to disable keyboard input to remap a key. For example, if I wanted to send 'a' when I press the 's' key, I can c...
A KenKen puzzle is a Latin square divided into edge-connected domains: a single cell, two adjacent cells within the same row or column, three cells arranged in a row or in an ell, etc. Each domain has a label which gives a target number and a single arithmetic operation (+-*/) which is to be applied to the numbers in the cells of the do...
Is there a cleaner way to write long regex patterns in python? I saw this approach somewhere but regex in python doesn't allow lists.
patterns = [
re.compile(r'<!--([^->]|(-+[^->])|(-?>))*-{2,}>'),
re.compile(r'\n+|\s{2}')
]
...
Before I have the audacity to file a bug report, I thought I'd check my assumptions among wiser Pythonistas here. I encountered a baffling case today, so I whittled it down to a toy example, shown below:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
A little script to demonstrate that a function won't re-initialize its
list paramet...
i want to code in python and i know the syntax well.. but i have got no idea how to compile and run it ..!! i mean i am from ruby , java , c , c++ background and there after saving it in a file we go to command prompt and type the command and the file name to compile and run it .
then what about python ?
why does python filename.py doesn...
I have a text string that starts with a number of spaces, varying between 2 & 4. What's the easiest & simplest way to remove them ie. remove everything before a certain character?
Cheers!
...
i want to take inputs like this
10 12
13 14
15 16
..
how to take this input , as two diffrent integers so that i can multiply them in python
after every 10 and 12 there is newline
...
I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framework, and a testing lib...
I have an image/pixbuf that I want to draw into a gtk.DrawingArea and refresh frequently, so the blitting operation has to be fast. Doing it the easy way:
def __init__(self):
self.drawing_area = gtk.DrawingArea()
self.image = gtk.gdk.pixbuf_new_from_file("image.png")
def area_expose_cb(self, area, event):
self.drawing_area.window...
A python program needs to draw histograms. It's ok to use 3rd party library (free). What is the best way to do that?
...
I'm trying to find a pythonic way to do this PHP code:
chunk_split(base64_encode($picture));
http://us2.php.net/chunk_split
chunk_split split the string into smaller chunks of 76 character long by adding a "\r\n" (RFC 2045).
thank you
...
I'm trying to serialize some data to xml in a way that can be read back. I'm doing this by manually building a DOM via xml.dom.minidom, and writing it to a file using the included writexml method.
Of particular interest is how I build the text nodes. I do this by initializing a Text object and then setting its data attribute. I'm not su...
I'm using django.core.mail.EmailMultiAlternatives when sending e-mails from my django app in an attempt to make sure that the message downgrades to text if the e-mail client doesn't support HTML.
Here is my send_email method:
def send_email(self, from_address, to_list, subject, msg_text, msg_html):
subject=subject.replace('\r',...