Skip to content

Instantly share code, notes, and snippets.

@vasmedvedev
Created July 27, 2016 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasmedvedev/09186c76591274553e317cd442ec2f22 to your computer and use it in GitHub Desktop.
Save vasmedvedev/09186c76591274553e317cd442ec2f22 to your computer and use it in GitHub Desktop.
Module ma
class Parent(object):
pass
class MyError(Exception):
pass
class isSecondField(object):
def __init__(self, value):
self.value = value
def __set__(self, obj, value):
raise AttributeError
def __get__(self, obj, type=None):
return self.value
class First(Parent):
isSecond = isSecondField(False)
@staticmethod
def isFirst():
return True
class Second(Parent):
isSecond = isSecondField(True)
@staticmethod
def isFirst():
return False
class A(First):
def __init__(self):
self.i = 3
@staticmethod
def fnc(a):
if a == 7:
raise MyError("Error text")
return a * a * 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment