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 MyAbstractProperty(object): | |
__metaclass__ = abc.ABCMeta | |
@abc.abstractproperty | |
def xname(self): pass | |
class MyAbstractPropertySubclass(MyAbstractProperty): | |
@property |
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 MyPropertyValidation(object): | |
def __init__(self): | |
self.__age = None | |
@property | |
def age(self): | |
if not self.__age: | |
raise ValueError("Age is None and needs to be set first.") | |
return self.__age |
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 MyPropertyValidation(object): | |
def __init__(self): | |
self.__age = None | |
@property | |
def age(self): | |
if not self.__age: | |
raise ValueError("Age is None and needs to be set first.") | |
return self.__age |
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 MyProperty(object): | |
def __init__(self, name): | |
self.__name = name | |
@property | |
def xname(self): | |
return self.__name | |
@xname.setter | |
def xname(self, val): |
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
def qsort2(data): | |
if data==[]: | |
return data | |
mid=len(data)/2 | |
pivot=data.pop(mid) | |
less=qsort2(filter(lambda x:x<pivot,data)) | |
great=qsort2(filter(lambda x:x>=pivot,data)) | |
return less+[pivot]+great |
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
def qsort(data): | |
if data==[]: | |
return data | |
pivot=data[0] | |
less=qsort([x for x in data[1:] if x<pivot]) | |
great=qsort([x for x in data[1:] if x>=pivot]) | |
return less+[pivot]+great |
NewerOlder