Instance of class "object"

甜瓜 littlesweetmelon at gmail.com
Fri May 16 04:46:40 EDT 2008


Howdy,
    I wonder why below does not work.

a = object()
a.b = 1        # dynamic bind attribute failed...

To make it correct, we have to create a new class:
class MyClass(object): pass
a = MyClass()
a.b = 1       # OK

Does this strange behavior break the LSP (Liskov substitution principle)?

    Regards,
--
ShenLei



More information about the Python-list mailing list