daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. " Python 2 version "
  2.  
  3. class MyMetaclass(type):
  4.  
  5.     def __new__(cls, name, bases, dct):
  6.  
  7.         attrs = ((name, value) for name, value in dct.items() if not name.startswith('__'))
  8.         attrs = dict(("__" + name.upper(), value) for name, value in attrs)
  9.  
  10.         return super(MyMetaclass, cls).__new__(cls, name, bases, attrs)
  11.  
  12.  
  13. class BaseClass(object):
  14.     __metaclass__ = MyMetaclass
  15.  
  16. class Banana(BaseClass):
  17.     v = 10
  18.  
  19.  
  20. if __name__ == '__main__':
  21.  
  22.     kk = Banana()
  23.  
  24.     try:
  25.         print "kk.v is: %s" % kk.v
  26.     except AttributeError:
  27.         print "There is not a 'kk.v' here"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top