adding all files done so far
This commit is contained in:
18
learning/descriptors/descriptors.py
Normal file
18
learning/descriptors/descriptors.py
Normal file
@@ -0,0 +1,18 @@
|
||||
class Person(object):
|
||||
"""docstring for Person"""
|
||||
def __init__(self, name, age):
|
||||
super(Person, self).__init__()
|
||||
self.name = name
|
||||
self.age = age
|
||||
|
||||
@property
|
||||
def age(self):
|
||||
print('old enough')
|
||||
return self.__age
|
||||
|
||||
@age.setter
|
||||
def age(self, value):
|
||||
if value < 21:
|
||||
raise Exception(f'{self.name} is not old enough.')
|
||||
else:
|
||||
self.__age = value
|
||||
Reference in New Issue
Block a user