On 5/1/06, John Keyes <[EMAIL PROTECTED]> wrote: > > No. Late binding of sys.argv is very important. There are plenty of > > uses where sys.argv is dynamically modified. > > Can you explain this some more? If it all happens in the same > function call so how can it be late binding?
You seem to be unaware of the fact that defaults are computed once, when the 'def' is executed (typically when the module is imported). Consider module A containing this code: import sys def foo(argv=sys.argv): print argv and module B doing import sys import A sys.argv = ["a", "b", "c"] A.foo() This will print the initial value for sys.argv, not ["a", "b", "c"]. With the late binding version it will print ["a", "b", "c"]: def foo(argv=None): if argv is None: argv = sys.argv print argv -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com