Another Tutorial on Python Classes.
This is a great YouTube tutorial that deals with several special class methods. First, there is brief mention of the constructor method, which was dealt with in the previous posts.
Second the string method is mentioned: (3.33). This method, if present, prints out what ever you tell it to print out about the self object. Whatever is printed out is contained in the string following the return statement
def __str__ (self):
return ('(0)is (1) years old.'.format(self.name, self.age)
The delete method __def__ (self) is next discussed. When called, this method deletes an object. To delete an object, call the function and supply the object name.
Class variables. These are stored in the class and not within a particular method. Any method can access a class variable.
Finally static methods are discussed. These are methods independent of the self object.
Great tutorial! take a look at it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment