I am testing classes that parse XML and create DB objects (for a Django app).
There is a separate parser/creater class for each different XML type that we read (they all create essentially the same objects). Each parser class has the same superclass so they all have the same interface.
How do I define one set of tests, and provide a l...
I'm trying to write a simple mail retrieval program in python. It seems the connection is getting established. But when I try to authorize it with the username, I don't get a reply from the server. Can anyone tell me what is going wrong here?
import socket, sys
from OpenSSL import SSL
ctx = SSL.Context(SSL.SSLv23_METHOD)
print "Creat...
Based on a question I previously asked, I tried to come up with a class property that would allow setting as well as getting. So I wrote this and put it in a module util:
class classprop(object):
def __init__(self, fget, fset=None):
if isinstance(fget, classmethod):
self.fget = fget
else:
sel...
Hey, new to Django and needing assistance, when I add my model to the admin interface in Django it appeares fine, but when I try to add or delete an entry in the database I get:
TypeError at /admin/Users/user/add/
coercing to Unicode: need string or buffer, tuple found
I done a google search and added:
def __str__(self):
re...
Hi, the title says nearly all I want: How do I convert a datetime.datetime object (e.g. the return value of datetime.datetime.now()) to a datetime.date object in Python?
...
I am doing this:
import sys, codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
But I know there is something missing. I had a huge collection of code before an HD crash, and my snippet in there had something in it which prevented:
reload(sys)
From undoing the codec changes. D...
I'm using Django and want to be able to store classes in a database for things like forms and models so that I can easily make them creatable through a user interface since they are just stored in the database as opposed to a regular file. I don't really know a whole lot about this and am not sure if this is a situation where I need to u...
I keep hitting road blocks with Django and have read about Pylons. Pylons seemed to be exactly what I needed (greener grass), but then I realized that they have global variables all over the place and loads of black magic infused by dark spirits (spirits so dark that they even kill unicorns).
Is there anything out there that is enterpri...
Is there a Python equivalent to Ruby symbols?
If so then what is it?
If not then are we stuck with using strings as our keys in dictionaries only?
...
I've been using WxPython and I've tried Tk, but it seems that, while both are good and I'll likely use them for other projects, neither of those appear to be capable of accomplishing the things that I want for my current project (which is fine, they're good at what they do).
Basically what I'm looking for is something that will allow me...
I have a config file that the user can specify sections, and then within those section they can specify regular expressions. I have to parse this config file and separate the regex's into the various sections.
Is there an easy way to delimitate a regex from a section header? I was thinking just the standard
[section]
regex1
regex2
B...
I want to transmit data from a Queue using Twisted. I currently use a push producer to poll the queue for items and write to the transport.
class Producer:
implements(interfaces.IPushProducer)
def __init__(self, protocol, queue):
self.queue = queue
self.protocol = protocol
def resumeProducing(self):
...
Hi have made one source in python for get fundamental frequecys from audio files, i want use this for get tones from DTMF audios !
but how get the low tones from the audio?
thks!!
...
So I have this TreeView/TreeStore, which I fill with data from a list. My application uses only said list as reference data. The TreeStore is just constructed for display. And the TreeView can be resorted by tipping the column headers. Because .set_sort_column_id() was used for initialization of each column.
Problem is, following code a...
Can someone tell me how to make my script callable in any director? My script simply returns the number of files in a directory. I would like it to work in any directory by invoking it, instead of first being copied there and then typing python myscript.py
I am using Mac OS X, but is there a common way to get it installed on Windows and...
I am looking for a way to decrypt pgp messages in python without the use of a subprocess. I have checked out http://wiki.python.org/moin/GnuPrivacyGuard but none of those solutions worked. Pyme almost worked except I hit a wall when trying to use set_passphrase_cb to avoid any user interaction but couldn't get it working ( http://stackov...
I have a list of tuples:
[(3,4), (18,27), (4,14)]
and need a code merging tuples which has repeated numbers, making another list where all list elements will only contain unique numbers. The list should be sorted by the length of the tuples, i.e.:
>>> MergeThat([(3,4), (18,27), (4,14)])
[(3,4,14), (18,27)]
>>> MergeThat([(1,3), (15,...
I made a tkinter window in python with some widgets like so:
def createWidgets(self):
self.grid(padx=25, pady=25)
self.start = Button(self)
self.start["text"] = "Start"
self.start["width"] = "15"
self.start["height"] = "1"
self.start["command"] = self.start_g
self.start.grid(row=0, colu...
Hi.
I'm trying to get Mako render some string with unicode characters :
tempLook=TemplateLookup(..., default_filters=[], input_encoding='utf8',output_encoding='utf-8', encoding_errors='replace')
...
print sys.stdout.encoding
uname=cherrypy.session['userName']
print uname
kwargs['_toshow']=uname
...
return tempLook.get_template(page).re...
One of my most common bugs is that I can never remember whether something is a method or a property, so I'm constantly adding or removing parentheses.
So I was wondering if there was good logic behind making the difference between calling on an object's properties and methods explicit.
Obviously, it allows you to have properties and me...