Re: Creating Class Objects in Loop
- From: "D'Arcy J.M. Cain" <darcy@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 11:51:46 -0400
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.
.
- References:
- Creating Class Objects in Loop
- From: Fish
- Re: Creating Class Objects in Loop
- From: John Nagle
- Creating Class Objects in Loop
- Prev by Date: Re: Build complete, now I just need to "install" it...
- Next by Date: Re: License of Python
- Previous by thread: Re: Creating Class Objects in Loop
- Next by thread: Re: cheap wholesale,Timberland ( cheap accept ) ( www.top-saler.com )
- Index(es):
Relevant Pages
|