What am I doing wrong?
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Sep 21 11:22:21 EDT 2005
keithlackey wrote:
> I'm relatively new to python and I've run into this problem.
This has two very standard mistakes:
First, as noted by Sybren, messages should just use spaces in order to
be readable.
After correcting that one:
> class structure:
> def __init__(self, folders = []):
> self.folders = folders
> ...
Here is the second one. Default args are not rebuilt, but shared.
The correct way to do this is:
class structure:
def __init__(self, folders=None):
if folders is None:
self.folders = []
else:
self.folders = folders
...
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list