Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi, Chris Thanks for the suggestion. For my script, I want to download a picture from internet & show it in a window, that's why I use wxPython. Well, I think I may can avoid sleep in wxPython in 2 ways: 1. Use web.py, let python do backend work, let browser show me everything. As you suggeste

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi, Chris & Marko Thanks for your reply. I find the reason why my time.sleep take longer time. In my script, I use wxPython to build up my GUI, and I open another thread to do network communications. It turned out that if you create a wx.Frame & make it show up, then your time.sleep may sleep l

Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi. I'm writing some scripts with python, and I found sometimes, when I try to use time.sleep(1) to sleep 1 sec, it would actually sleep for 9 secs or even longer. >From python document, I saw this: time.sleep(secs) Also, the suspension time may be longer than requested by an arbitrary amo

Re: keeping twisted and wxPython in sync

2012-02-07 Thread crow
On Feb 8, 2:41 am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory afte

Re: keeping twisted and wxPython in sync

2012-02-07 Thread crow
On Feb 8, 2:41 am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory afte

Is there anyway to use urllib2 to download a file from http server?

2011-09-10 Thread crow
As the title. Or is there other module that can handle this task? Many thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Is there anyway to check the number of I/O registered in poll?

2011-03-29 Thread crow
I'm using select.poll to do I/O polling. polling is placed in a independent thread from select import poll _poller = poll() def poll(timeout): l = _poller.poll(timeout) return l In my code, in some context, the timeout value will be high ( like 1 hour ), but there is no I/O in _p

Is there anyway to run JavaScript in python?

2010-12-30 Thread crow
Hi, I'm writing a test tool to simulate Web browser. Is there anyway to run JavaScript in python? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why there is no "setdefaultencoding" in sys module?

2010-07-09 Thread crow
On Jul 10, 12:06 am, crow wrote: > On Jul 10, 12:04 am, Steven D'Aprano > > > > > cybersource.com.au> wrote: > > On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: > > > So, my questions: why there is no setdefaultencoding in sys module? if I > > &

Re: Why there is no "setdefaultencoding" in sys module?

2010-07-09 Thread crow
On Jul 10, 12:04 am, Steven D'Aprano wrote: > On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: > > So, my questions: why there is no setdefaultencoding in sys module? if I > > want to change system's default encoding, what should I do? > > I think the answer is: >

Why there is no "setdefaultencoding" in sys module?

2010-07-09 Thread crow
Hi, everyone I'm a new hand at python. I tried to set system default encoding by using "import sys; sys.setdefaultencoding('utf-f')", but I got error message: >>> sys.setdefaultencoding('utf-8') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has n

Re: insert unique data in a list

2009-12-13 Thread Fire Crow
> Also, I'm not sure I like your abuse of the + operator to modify the > object in place and return a flag. It is an API not shared by (as far as > I can see) any other data type in Python. I agree it couuld be more consisten with other object apis, I also think that if every api has to conform t

Re: insert unique data in a list

2009-12-13 Thread Fire Crow
On Dec 13, 11:37 am, mattia wrote: > How can I insert non-duplicate data in a list? I mean, is there a > particular option in the creation of a list that permit me not to use > something like: > def append_unique(l, val): >     if val not in l: >         l.append(val) > > Thanks, > Mattia You cou

Re: power of explicit self?

2009-12-12 Thread Fire Crow
> It's not implemented in the compiler. There's a place in the runtime > for invoking a method where the object is inserted at the beginning > of the parameter list. IIRC, that's done by wrapping the function > object. This is the source of Objects/methodobject.c it look like this is where self is

power of explicit self?

2009-12-11 Thread Fire Crow
I'm looking for an explanation of how explicit self is implimented and what features are only possible because of, or are greatly improved, because of it. I've always liked explicit self and am looking for the computer science behind it, so that I can explain the benefits that I see. I'm also inte