Created
July 27, 2016 10:31
-
-
Save vasmedvedev/09186c76591274553e317cd442ec2f22 to your computer and use it in GitHub Desktop.
Module ma
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 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