Re: Creating Class Objects in Loop



On Sun, 30 Mar 2008 21:34:00 -0700
John Nagle <nagle@xxxxxxxxxxx> wrote:
What's actually happening to you is that you've run into one of the
dumber features of Python - default values for parameters which are
mutable, like lists, result in rather unexpected behavior. The
problem is that

def __init__(self, pcap = None, sids = []):

I have never liked using that form for different reasons so I never
tripped over that. Now I have another reason to avoid it. It's not a
huge deal to do this.

def __init__(self, pcap = None, sids = None):
if sids is None: sids = []

--
D'Arcy J.M. Cain <darcy@xxxxxxxxx> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
.



Relevant Pages

  • Re: Change lists of one listbox based on selection of other listbo
    ... Also, drop-down lists are combo boxes, not list boxes. ... indicates which field in the underlying table the control is bound to; ... The RowSource property of a combo box indicates the source of the ... ControlSource of the reasons combo box should be set to the "reason code" ...
    (microsoft.public.access.forms)
  • Why questions dont get answered, or "No, Ive already RTFM, tell me the answer!"
    ... I'd like to start a calm, respectful, reasonable discussion of the reasons ... questions answered on mailing lists and usenet groups. ... Many lists and groups regularly autopost the guidelines for posting, FAQ, ... Does anyone else have any thoughts on why questions don't get the respectful ...
    (Fedora)
  • Re: request for abuse (critique a site)
    ... I was concerned about mouse accuracy in using the menus. ... the reasons I am hesitant to switch the default version over to the ... page is available that lists all the links, so there is always a way to ... > as transparencies. ...
    (alt.html)
  • explicit self revisited
    ... The Python FAQ 1.4.5 gives 3 reasons for explicit self: ... def testList: ... The current self syntax could still be valid ... One argument less for "Python OO bolted on" propaganda. ...
    (comp.lang.python)
  • Re: "Hooked on Hector?" Amazing Berlioz List from Amazon
    ... >> Don't spend too much time looking at those lists. ... > Robert Shaw's recording of the Requiem. ... Mr. Zeidler gives his reasons, ... And a Berlioz performance that is unremarkable simply misses the point. ...
    (rec.music.classical.recordings)