Skip to content

Instantly share code, notes, and snippets.

@elzibubble
Created March 21, 2016 11:06
Show Gist options
  • Save elzibubble/de0fb5d70cf89928435c to your computer and use it in GitHub Desktop.
Save elzibubble/de0fb5d70cf89928435c to your computer and use it in GitHub Desktop.
import os
FOO = None
class Foo(object):
this = None
def __init__(self):
Foo.this = self
global FOO
FOO = self
print "self: %s" % self
print "this: %s" % Foo.this
print "FOO : %s" % FOO
def main():
os.system('clear')
mod = __import__('vars')
klass = getattr(mod, 'Foo')
foo = klass()
print Foo.this
print FOO
print "-" * 20
foo = Foo()
print Foo.this
print FOO
if __name__ == '__main__':
main()
self: <vars.Foo object at 0x7fc5825dedd0>
this: <vars.Foo object at 0x7fc5825dedd0>
FOO : <vars.Foo object at 0x7fc5825dedd0>
None
None
--------------------
self: <__main__.Foo object at 0x7fc580e91f10>
this: <__main__.Foo object at 0x7fc580e91f10>
FOO : <__main__.Foo object at 0x7fc580e91f10>
<__main__.Foo object at 0x7fc580e91f10>
<__main__.Foo object at 0x7fc580e91f10>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment