Created
December 7, 2012 01:45
-
-
Save naquad/4230059 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_constants(name, bases, dict): | |
print name | |
for idx, i in enumerate(dict['HEADER']): | |
name = 'COLUMN_' + i.upper().replace(' ', '_') | |
dict[name] = idx + 1 | |
return type(name, bases, dict) | |
class Test: | |
__metaclass__ = setup_constants | |
HEADER = ['Item', 'Qty', 'Unit price'] | |
def __init__(self): | |
pass | |
def t(self): | |
print self.COLUMN_ITEM | |
class T2(Test): | |
HEADER = ['Test', 'Item'] | |
print T2.COLUMN_ITEM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment