Wednesday, May 16, 2012
Monday, February 20, 2012
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.
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.
Sunday, February 19, 2012
Python Classes
Each Python Class has a constructor method which is responsible for creating an instance of the object when the class is called. The constructor method is written just after the class is declared. The constructor method is called using the __init___ command. Python actually calls the method and passes the user-supplied name to the method as a parameter. The YouTube video below gives a good introduction to Python Classes.
Each Python Class has a constructor method which is responsible for creating an instance of the object when the class is called. The constructor method is written just after the class is declared. The constructor method is called using the __init___ command. Python actually calls the method and passes the user-supplied name to the method as a parameter. The YouTube video below gives a good introduction to Python Classes.
Friday, February 17, 2012
Saturday, February 11, 2012
Subscribe to:
Posts (Atom)