Python for Java Programmers
Chapter 8: Object-oriented programming
Object-oriented programming in Python
You should have gotten the point by now that everything is an object in Python.
Here is a reminder of how to define a class and instantiate a class instance.
1 2 3 4 5 6 7 |
|
While the general OOP concepts are the same as in Java, there are many specific details in Python where things are implemented differently. Some of these requires a different way of thinking from what you have been exposed to in Java.
Before you start defining classes for everything, if all you really need is a struct
, then perhaps you should consider using a dict
instead of a class?