What happens to module's variables after a "from module import" ?

ast nomail at com.invalid
Tue Nov 7 10:56:46 EST 2017


"Paul Moore" <p.f.moore at gmail.com> a écrit dans le message de 
news:mailman.53.1510069830.2819.python-list at python.org...
> On 7 November 2017 at 15:39, ast <nomail at com.invalid> wrote:

>
> It's in the "tmp" module, where you defined it. But because you didn't
> ask for a reference to it in your import statement, it's not
> accessible to you[1].
> Do
>
>    import tmp
>    print(tmp.a)
>
> and you can see it.
>
> Paul
>
> [1] Technically you can find it via the globals of the function test,
> as test.__globals__['a'], but if you understand how that works, you
> wouldn't have been asking the question in the first place :-)

Clear, ty 




More information about the Python-list mailing list