reorx
11/6/2013 - 2:49 AM

scope_of_main_dict_and_global.py

# testa.py

import __main__
from testb import get_globals


if __name__ == '__main__':
    print locals() is locals()
    print globals() is globals()
    print __main__.__dict__ is globals()
    print __main__.__dict__ is get_globals()


# testb.py

def get_globals():
    return globals()


# $ python testa.py
# True
# True
# True
# False