Classes/Objects


Classes are constructors that are used as a template to build objects.

Classes are defined with the class keyword, followed by the classes name. 

Classes use the __init__() function to assign values to object properties.

Classes use the __str__() function to control what is returned when the object is represented as a string.

Methods in the context of objects refer to a function within an object, that belongs to and is contained by the object.

Self refers to the current instance of a class and is used to access its variables. It does not have to be called self, but usually is, so use it for clarity.

Objects and their properties can be deleted with the del keyword, and modified with =. 

Leave a comment

Log in with itch.io to leave a comment.