On 5/1/06, John Keyes <john at integralsource.com> 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/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4