a guest Oct 12th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- " Python 2 version "
- class MyMetaclass(type):
- def __new__(cls, name, bases, dct):
- attrs = ((name, value) for name, value in dct.items() if not name.startswith('__'))
- attrs = dict(("__" + name.upper(), value) for name, value in attrs)
- return super(MyMetaclass, cls).__new__(cls, name, bases, attrs)
- class BaseClass(object):
- __metaclass__ = MyMetaclass
- class Banana(BaseClass):
- v = 10
- if __name__ == '__main__':
- kk = Banana()
- print "kk.v is: %s" % kk.v
- except AttributeError:
- print "There is not a 'kk.v' here"
RAW Paste Data