After having read this far, you should not be surprised to hear that Python’s object orientation is flexible and likely to surprise you if you have been using C-like languages for several years.
The best way to learn Python
object-oriented programming (OOP) is to just do it. So, here is a basic script that defines a class, creates an object of that class, and calls a function:
class Dog(object): def bark(self): print "Woof!"fluffy = Dog()fluffy.bark()
Defining a class starts, predictably, with the
class keyword followed by the name of the class you are defining and a colon. The contents of that class need to be indented one level so that Python knows where it stops. Note that the object inside parentheses is there ...