>>>>> "Christoph" == Christoph Haas <[EMAIL PROTECTED]> writes:
Christoph> Hi, list... I wondered if it's possible to use global
Christoph> (module) variables as default parameters. A simple
Christoph> working example:
Christoph> ----------------------------------------
Christoph> #!/usr/bin/python
Christoph> globalvar = 123
Christoph> def test(foo=globalvar): print foo
kwargs defaults are initialized a module load time, not at function
call time. The standard idiom is
def test(foo=None):
if foo is None: foo = globalvar
print foo
JDH
--
http://mail.python.org/mailman/listinfo/python-list