Method 1. Properties
class Student (Object): DEF the __init__ (Self, name): the self.name = name @Property # property methods: a method for the property or into a static variable. DEF Fly (Self): Print ( ' {...} Fly ' .format (the self.name)) A = Student ( ' WDC ' ) a.fly # can invoke method call attribute properties manner
2.
class Student (Object): DEF the __init__ (Self, name): the self.name = name @Property # property methods: a method for the property or into a static variable. DEF Fly (Self): Print ( ' {...} Fly ' .format (the self.name)) A = Student ( ' WDC ' ) a.fly # can invoke method call attribute properties manner a.fly = 100 # but I can not give this property reassigned
3. The method of passing parameters to the property: Review
class Student (Object): DEF the __init__ (Self, name): the self.name = name @Property # property methods: a method for the property or into a static variable. DEF Fly (Self): Print ( ' {...} Fly ' .format (the self.name)) @ fly.setter DEF Fly (Self, Age): # accepts the passed parameter Print ( ' {} years ' . the format (Age)) a = Student ( ' WDC ' ) a.fly # can be invoked by a method invocation attribute properties manner a.fly = 22 is #Properties pass parameters to methods
4. Remove Properties Methods
class Student (Object): DEF the __init__ (Self, name): the self.name = name @Property # property methods: a method for the property or into a static variable. DEF Fly (Self): Print ( ' {...} Fly ' .format (the self.name)) @ fly.setter DEF Fly (Self, Age): # accepts the passed parameter Print ( ' {} years ' . the format (Age)) @ fly.deleter DEF Fly (Self): Print ( ' del ... ' ) A = Student (' WDC ' ) a.fly # can be invoked by a method invocation attribute way attribute 22 is a.fly = # pass parameters to methods properties del a.fly # Methods del execution attribute is @ fly.deleter method performed following