This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jhewitt
Recipients jhewitt, matrixise, steven.daprano
Date 2018-10-25.20:48:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <67307bb5-1b3e-c6dc-7688-2d7634c1ec69@caurinus.com>
In-reply-to <20181025203226.GN3817@ando.pearwood.info>
Content
So just the fact that somewhere in the function a name is referenced, 
even if that code isn't actually executed, is enough to change the local 
namespace.  I think I knew that, but didn't know that's what it meant :)

I guess the moral is, pay attention to scope when importing submodules 
dynamically.

Thanks for looking at this, sorry it wasn't a bit more interesting :)

-James

On 10/25/2018 01:32 PM, Steven D'Aprano wrote:
> 
> Steven D'Aprano <steve+python@pearwood.info> added the comment:
> 
> Yes, that's exactly right. That's how local variables work in Python:
> 
> x = 999  # global x
> def demo():
>     if False:
>         x = 1
>     x  # local x has no value
> 
> does the same thing. This is standard, documented behaviour, regardless
> of which kind of assignment statement you use.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue35069>
> _______________________________________
>
History
Date User Action Args
2018-10-25 20:48:04jhewittsetrecipients: + jhewitt, steven.daprano, matrixise
2018-10-25 20:48:04jhewittlinkissue35069 messages
2018-10-25 20:48:04jhewittcreate