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 steven.daprano
Recipients stars-of-stras, steven.daprano
Date 2021-09-27.14:44:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20210927143938.GV11377@ando.pearwood.info>
In-reply-to <1632751773.69.0.135627051862.issue45294@roundup.psfhosted.org>
Content
I'm glad that you fixed the bug in your code, but this is not a bug in 
Python. It isn't "a parsing issue", the code is parsed fine. What you 
did was no different from:

    def func():
        print(x)
        x = 1

except that the binding operation was an import, not an assignment. You 
get exactly the same error here:

    def func():
        print(math)
        import math

That's the way the language is defined. Imports and assignments are both 
binding operations and are treated the same by the interpreter. It's not 
an accident or a mistake or a parsing issue or a bug, it is the way the 
language is supposed to work.
History
Date User Action Args
2021-09-27 14:44:24steven.dapranosetrecipients: + steven.daprano, stars-of-stras
2021-09-27 14:44:24steven.dapranolinkissue45294 messages
2021-09-27 14:44:24steven.dapranocreate