A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/344463.html below:

What am I doing wrong?

What am I doing wrong? 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4