Weird asyncore behaviour
Erik Max Francis
max at alcyone.com
Sun Nov 2 23:32:33 EST 2003
Freddie wrote:
> class async_http(asyncore.dispatcher):
> def __init__(self, parent, returnme, url, seen={}):
^^
This is your problem. Default arguments are only created once, so the
default seen argument is the same physical object shared by all
invocations of that method. That isn't what you want, as it will
accumulate changes.
Instead use the idiom:
def f(dictArg=None):
if dictArg is None:
dictArg = {} # create a new one each time
...
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ I never loved another person the way I loved myself.
\__/ Mae West
More information about the Python-list
mailing list