Skip to content

Instantly share code, notes, and snippets.

@capttwinky
Created July 16, 2013 17:25
Show Gist options
  • Save capttwinky/6010734 to your computer and use it in GitHub Desktop.
Save capttwinky/6010734 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
GLOBALS=type('GLOBALS',(object,),{
'my_d': 0
}
)()
my_e = 0
def inc_d(n):
GLOBALS.my_d += n ## uses a namespace
print GLOBALS.my_d
def inc_e(n):
my_e += n ## no namespace used, must be local
print my_e
inc_d(10)
inc_e(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment