Everything is an object in python - object class and type class
Ian Kelly
ian.g.kelly at gmail.com
Wed Jun 3 09:57:47 EDT 2015
On Wed, Jun 3, 2015 at 2:57 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
>
>> On Wednesday 03 June 2015 08:33, Marko Rauhamaa wrote:
>>> In Python, classes are little more than constructor functions.
>>
>> [...]
>>
>> Classes give you an inheritance hierarchy.
>
> That's encapsulated in the constructor.
Not entirely true.
>>> class A:
... def say_hi(self):
... print("Hello!")
...
>>> class B:
... def say_hi(self):
... print("G'day!")
...
>>> obj = A()
>>> obj.say_hi()
Hello!
>>> obj.__class__ = B
>>> obj.say_hi()
G'day!
More information about the Python-list
mailing list