Function __defaults__

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Apr 24 05:58:32 EDT 2011


Consider this in Python 3.1:
>>> def f(a=42):
... return a
...
>>> f()
42
>>> f.__defaults__ = (23,)
>>> f()
23
Is this an accident of implementation, or can I trust that changing 
function defaults in this fashion is guaranteed to work?
-- 
Steven


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /