help: Unit test fixture returning the same object

Michael McCracken mmccrack at ucsd.edu
Wed Aug 4 16:54:22 EDT 2004


In article <cerh48$csd$01$1 at news.t-online.com>,
 Peter Otten <__peter__ at web.de> wrote:

> Michael McCracken wrote:
> 
> > I managed to fix my problem, but I don't understand why the fix works
> > yet, so I'm not quite satisfied.
> 
> [...] 
> 
> > class Block:
> >     def __init__(self, name, preds = [], succs = []):
> 
> Heureka! Providing mutables as default values is a well-known pitfall. 
> 
> http://www.python.org/doc/faq/general.html#why-are-default-values-shared-betwe
> en-objects
> 

Oh, excellent - thanks for the pointer. Time to read the rest of the 
FAQ. :)

-mike



More information about the Python-list mailing list