Ronald Oussoren <ronaldousso...@mac.com> added the comment:
>From the zip file, the "bug" is: # ---- def parent_function2( argument1 ): def child_function(): print( argument1 ) if False: argument1 = None # Same function but with fake assignment return child_function # ---- This doesn't work because "argument1" is a local variable in the nested function, and not the same as "argument1" in the outer function. This is expected behavior. The workaround from the same zipfile is to assign the argument of the outer function to a local variable in that outer function, that way the value can be used in the inner function. That is a valid way to deal with this, although I'd use a different name in the inner function. The "nonlocal" keyword in Python 3 might be useful here, but that depends on whether or not you want changes to "argument1" in the inner function to affect the value of "argument1" in the outer function. All in all I don't think there's a bug in Python here. ---------- nosy: +ronaldoussoren _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33527> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com