newbie question
maxm
maxm at mxm.dk
Sun Jan 13 16:20:49 EST 2002
More information about the Python-list mailing list
Sun Jan 13 16:20:49 EST 2002
- Previous message (by thread): newbie question
- Next message (by thread): Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"rihad" <rihad at mail.ru> > def f(n, x = []): > # some code > > Even if I don't modify x inside f(), is it guaranteed that x will > always be [], that is, the empty list [] will never be shared with > some unrelated reference, which could modify it, and thus affect what > x binds to? Maybe what you want is:: def f(n, x = None): if x == None: x = [] # some code Then x will not be shared with anything else. So don't use a mutable object as default value in a parameterlist in that case. regards Max M
- Previous message (by thread): newbie question
- Next message (by thread): Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list