Why don't optional mutable objects show up in vars(func)?
Sean Hammond
s0094060 at sms.ed.ac.uk
Wed Sep 27 13:22:27 EDT 2006
More information about the Python-list mailing list
Wed Sep 27 13:22:27 EDT 2006
- Previous message (by thread): Battlefield Weapon Popularity Trend
- Next message (by thread): Why don't optional mutable objects show up in vars(func)?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 2006-09-27 at 09:32 -0700, dannycolligan at gmail.com wrote: > So I just got bitten by the "don't use a mutable object as an optional > argument" gotcha. I now realize that for this function: > > >>> def func(x, y=[]): > ... y.append(x) > ... print y > ... > > y is initialized when the function is imported, not when the function > is executed. I thought it was initialised the first time the function gets called?
- Previous message (by thread): Battlefield Weapon Popularity Trend
- Next message (by thread): Why don't optional mutable objects show up in vars(func)?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list