[Tutor] My first python gotcha

Kalle Svensson kalle@lysator.liu.se
Mon, 13 May 2002 23:48:55 +0200


[dominic.fox]
> Looked like this:
...
>     def addState(self, name, rules=[]):
>         self.states[name] = rules
...
> The assignment rules=[] in addState was what got me. Every time I
> added a rule, it got added to everything...

Yes, this is a classic.  More information available here:
http://python.org/doc/current/tut/node6.html#SECTION006710000000000000000

Peace,
  Kalle
-- 
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.