R. David Murray <rdmur...@bitdance.com> added the comment:

In fact, to hopefully make perfectly clear what is going on here, let me 
demonstrate that *any* executable statement in the module that fails to load is 
executed if it occurs before the error that causes the load failure:

    rdmurray@hey:~/python/p32>cat temp.py
    import os

    print('foo:', hasattr(os, 'foo'))

    try:
        import temp2
    except AttributeError:
        print('attribute error')

    print('temp2:', 'temp2' in globals())
    print('foo:', hasattr(os, 'foo'))
    rdmurray@hey:~/python/p32>cat temp2.py
    import os

    os.foo = 2
    os.bar

    rdmurray@hey:~/python/p32>./python temp.py
    foo: False
    attribute error
    temp2: False
    foo: True

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12554>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to