On Wed, Jun 3, 2015 at 2:57 AM, Marko Rauhamaa <ma...@pacujo.net> wrote:
> Steven D'Aprano <steve+comp.lang.pyt...@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!
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to