Created
February 7, 2011 15:23
-
-
Save fajran/814525 to your computer and use it in GitHub Desktop.
meta.py
This file contains 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
class MetaProvinsi(type): | |
def __new__(cls, name, bases, attrs): | |
return type.__new__(cls, name, bases, attrs) | |
class Provinsi(object): | |
__metaclass__ = MetaProvinsi | |
class MetaKabupaten(type): | |
def __new__(cls, name, bases, attrs): | |
attrs['nama_kelas'] = name | |
return type.__new__(cls, name, bases, attrs) | |
class Kabupaten(object): | |
__metaclass__ = MetaKabupaten | |
# p = Provinsi() | |
# print p.nama_kelas | |
k = Kabupaten() | |
print k.nama_kelas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment