acting on items passed to a method via a dictiomary

Diez B. Roggisch deetsNOSPAM at web.de
Sun Oct 17 19:33:32 CEST 2004


> However, there are no problems whatsoever with the issue you remark on,
> as long as the method never alters the 'items' object.  As long as only
> nonmutating methods get called on 'items', i.e., 'items' is practically
> treated as "read-only", Donnal Walter's approach is just fine.  The
> issue you remark on does deserve to be made, but it's also important to
> understand when it does matter and when it doesn't.

You are right of course, but the high frequency of postings regarding
"strange default value behaviour" made me want to make this point before
Donnal steps into that pitfall. And while the example at hand didn't alter
the contents of items, I'd nevertheless settled for items=None and used
something like this:

def foo(items=None):
    if not items is None:
        ....


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list