python

object won't die (still references to it that I can't find)

I'm using parallel-python and start a new job server in a function. after the functions ends it still exists even though I didn't return it out of the function (I used weakref to test this). I guess there's still some references to this object somewhere. My two theories: It starts threads and it logs to root logger. My questions: can I...

How can I convert this string to list of lists?

Hi, what I'm trying to do is.. if a user types in [[0,0,0], [0,0,1], [1,1,0]] and press enter, the program should convert this string to several lists; one list holding [0][0][0], other for [0][0][1], and the last list for [1][1][0] I thought tuple thing would work out but no luck... :( I started python yesterday -- (I'm C / C++ guy....

what is the recommended python frameworks for distributed computing?

hi('/') i am writing an application that need to be distributed on different nodes. what is the recommended framework. ...

ProgrammingError: (1146, "Table 'test_<DB>.<TABLE>' doesn't exist") when running unit test for Django

I'm running a unit test using the Django framework and get this error. Running the actual code does not have this problem, running the unit tests creates a test database on the fly so I suspect the issue lies there. The code that throws the error looks like this member = Member.objects.get(email=email_address) and the model looks li...

matplotlib equivalent for MATLABs truesize()

I am new to matplotlib and python and would like to display an image so that 1 pixel of the image is actually represented by 1 pixel in the figure. In MATLAB, this is achieved with the command truesize(). How can I do this in Python? I tried playing around with the imshow() arguments as well as set_dpi() and set_figwidth()/set_figheight...

How to ignore windows proxy settings with python urllib?

I want Python to ignore Windows proxy settings when using urllib. The only way I managed to do that was disabling all proxy settings on Internet Explorer. Is there any programmatic way? os.environ['no_proxy'] is not a good option, since I'd like to avoid proxy for all addresses. ...

sending the data from form to db in django

I have a form in which I can input text through text boxes. How do I make these data go into the db on clicking submit. this is the code of the form in the template. <form method="post" action="app/save_page"> <p> Title:<input type="text" name="title"/> </p> <p> Name:<input type="text" name="name"/> </p> <p> Phone:<input type="text" n...

Is there any lib for python that will get me the synonyms of a word?

Is there any api/lib for python that will get me the synonyms of a word? For example if i have the word "house" it will return "building, domicile, mansion, etc..." ...

tweepy documentation

Hi everybody I just began working on a little twitter-app using tweepy. is there any kind of useful (and complete) documentation for tweepy? I googled like hell but didn't find anything. greetings, Andy ...

Check if something is a list

What is the easiest way to check if something is a list? A method doSomething has the parameters a and b. In the method, it will loop through the list a and do something. I'd like a way to make sure a is a list, before looping through - thus avoiding an error or the unfortunate circumstance of passing in a string then getting back a let...

Is django orm & templates thread safe?

I'm using django orm and templates to create a background service that is ran as management command. Do you know if django is thread safe? I'd like to use threads to speed up processing. The processing is blocked by I/O not CPU so I don't care about performance hit caused by GIL. ...

how would i manage to install python's boto library on shared hosting?

how would i manage to install python's boto library on shared hosting? ...

What is the fastest (to access) struct-like object in Python?

I'm optimizing some code whose main bottleneck is running through and accessing a very large list of struct-like objects. Currently I'm using namedtuples, for readability. But some quick benchmarking using 'timeit' shows that this is really the wrong way to go where performance is a factor: Named tuple with a, b, c: >>> timeit("z = a...

tweepy stream.filter() method doesn't work properly

Hi there i've got some problems with the tweepy api. I'm just tryin to write a little app that gets me a stream of statuses of one user (ore more), but one would be fine to start with ;-) now: my code is like that: def main(): config = ConfigParser.ConfigParser() config.read('twitter.cfg') username = config....

How would I merged nested dictionaries in a list in python?

for example if i had the result [{'Germany': {"Luge - Men's Singles": 'Gold'}}, {'Germany': {"Luge - Men's Singles": 'Silver'}}, {'Italy': {"Luge - Men's Singles": 'Bronze'}}] [{'Germany': {"Luge - Women's Singles": 'Gold'}}, {'Austria': {"Luge - Women's Singles": 'Silver'}}, {'Germany': {"Luge - Women's Singles": 'Bronze'}}] [{'Austr...

python: how to design a container with elements that must reference their container

(the title is admittedly not that great. Please forgive my English, this is the best I could think of) I'm writing a python script that will manage email domains and their accounts, and I'm also a newby at OOP design. My two (related?) issues are: the Domain class must do special work to add and remove accounts, like adding/removing t...

Why urllib.urlopen doesn't (seem to) work with Stack Overflow?

I need to retrieve my info from Stack Overflow. The web page that I want to retrieve is something like this. http://stackoverflow.com/users/260127/prosseek When I run the script, it doesn't seem return any results. import urllib sock = urllib.urlopen("http://stackoverflow.com/users/260127/pros...

Threads or background processes in Google App Engine (GAE)

Hey, I'm running a post, and need the request to be replied fast. So I wanted to put a worker running some operations in background and reply the request imidiatly. The worker is always finite in operations and executes in [0;1] second How can I do this? Is there any module that suports this in the google app engine api? Edit: In py...

Python, implementing proxy support for a socket based application (not urllib2)

Hey guys, I am little stumped: I have a simple messenger client program (pure python, sockets), and I wanted to add proxy support (http/s, socks), however I am a little confused on how to go about it. I am assuming that the connection on the socket level will be done to the proxy server, at which point the headers should contain a CONNE...

Django manytomany, imageField and upload_to

Hello, I have the two models shown below: class EntryImage(models.Model): image = models.ImageField(upload_to="entries") class Entry(models.Model): code = models.CharField(max_length=70, unique=True) images = models.ManyToManyField(EntryImage, null=True, blank=True) As you can see, Entry can have 0 or more images. M...