summaryrefslogtreecommitdiff
path: root/pypers/final.py
blob: 811040c02095412dda10d93cf4de665a49fa3115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from oopp import *
class Final(Singleton,type):
    "Inherits the 'instance' attribute from Singleton (default None)"
    def __new__(meta,name,bases,dic):
        if meta.counter==0: # first call
            return super(Final,meta).__new__(meta,name,bases,dic)
        else:
            raise NonDerivableError("I cannot derive from %s" % bases)
  
class C:  __metaclass__=Final
try:
    class D(C): pass
except NonDerivableError,e:
    print e