How correctly add property to class that inherits Matrix class

17 views
Skip to first unread message

alexandr popov

unread,
Apr 21, 2012, 6:53:59 PM4/21/12
to sy...@googlegroups.com
Hi,

Can someone help me to resolve following uncertainty ?
I have class that inherits Matrix class. And when I trying to add a property to inherited class
I've got following:

   >>> a = SomeClass(10, 3, property=True)
   >>> a.property
   True
   >>> b = SomeClass(10, 2, property=False)
   >>> a.property
   False

Thanks,
Alexandr

alexandr popov

unread,
Apr 21, 2012, 8:18:13 PM4/21/12
to sy...@googlegroups.com
The problem is that I am using a cls.property = True in a __new__ method.

Solved by adding __init__ method inherited class implementation

Matthew Rocklin

unread,
Apr 21, 2012, 11:07:04 PM4/21/12
to sy...@googlegroups.com
cls refers to the class (SomeClass), not the object (b). 

On Sat, Apr 21, 2012 at 7:18 PM, alexandr popov <alexandr...@gmail.com> wrote:
The problem is that I am using a cls.property = True in a __new__ method.

Solved by adding __init__ method inherited class implementation

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/D2kgi6oViyIJ.

To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.

Reply all
Reply to author
Forward
0 new messages