Re: Python tricks

2009-01-12 Thread RajNewbie
On Jan 12, 6:51 pm, Tim Chase wrote: > >    My code has a lot of while loops of the following format: > >    while True: > >      ... > >      if : break > > >    The danger with such a code is that it might go to an infinite loop > > - if the never occurs. > >    Is there a way - a python trick

Python tricks

2009-01-12 Thread RajNewbie
Hi, My code has a lot of while loops of the following format: while True: ... if : break The danger with such a code is that it might go to an infinite loop - if the never occurs. Is there a way - a python trick - to have a check such that if the loop goes for more than x nu

Re: Twisted for non-networking applications

2008-12-21 Thread RajNewbie
On Dec 22, 3:26 am, "James Mills" wrote: > On Mon, Dec 22, 2008 at 4:27 AM, Kottiyath wrote: > > Hi all, > >   Is it a good idea to use Twisted inside my application, even though > > it has no networking part in it? > >   Basically, my application needs lots of parallel processing - but I > > am

Are python objects thread-safe?

2008-12-21 Thread RajNewbie
Say, I have two threads, updating the same dictionary object - but for different parameters: Please find an example below: a = {file1Data : '', file2Data : ''} Now, I send it to two different threads, both of which are looping infinitely: In thread1: a['file1Data'] = open(filename1).read

Re: 11001, 'getaddrinfo failed' : Error in httplib but not in urllib2

2008-12-01 Thread RajNewbie
On Dec 1, 7:43 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > RajNewbie wrote: > > Hi all, > >     I am trying to connect to localhost via httplib, but it fails. > >     To check whether it is a firewall problem etc, I tried to connect > > via urllib2, but it went

11001, 'getaddrinfo failed' : Error in httplib but not in urllib2

2008-12-01 Thread RajNewbie
Hi all, I am trying to connect to localhost via httplib, but it fails. To check whether it is a firewall problem etc, I tried to connect via urllib2, but it went through fine. Could some one help me out on this? I cannot use urllib2 in the program because I have to send files via post t