<dict>.setdefault()

Alexandre Fayolle alf at fayauffre.org
Thu Jul 31 12:54:46 EDT 2003


Tino Lange a écrit :
> I just realized that <dict>.setdefault *always* executes the second
> argument - even if it's not necessary, because the requested item in
> the first argument exists.
 
Since setdefault is a method, this is coherent with Python's standard
behaviour: method and function arguments are always evaluated before the
method is called. 

-- 
Alexandre Fayolle
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Développement logiciel avancé - Intelligence Artificielle - Formations




More information about the Python-list mailing list