You can see Object Oriented Programming (OOP) somewhat as a more advanced topic in Python where Python does implement it pretty well. Even though, Python does not require an OOP approach for making complex programs, it sometimes makes life easier while sometimes it doesn’t. Published on Dave’s RoboShack.
While Python scripts work pretty well without any implementation of Object Oriented Programming, it allows you to keep your code even more structured in form of Classes, Attributes and Methods.
In simple terms, a Class is a group of related variables and functions, all bound to a so called Object. Except, in the scope of OOP, you call the variables Attributes and the functions are called Methods. These objects are meant to behave similar to real-world objects with individual properties and things that can be done with them. The syntax of creating a class is fairly easy:
The article then describes and provides code examples for:
- Classes
- Attributes
- Methods
By convention, class names are written with the first letter as a capital letter, the remaining lowercase. If the class name is a compound word such as “Car Battery”, you would write each word starting with a capital letter: CarBattery. To learn more follow the link to the full article. Nice one!
[Read More]