I want to equip an Symbol with an additional attribute to store some
specific information right in place.
For 'normal' Python classes it is no problem to dynamically create an
additional attribute for an already existing instance.
However, for sympy Symbols if I try
x = Symbol('x')
x.k = 0
I get the error
AttributeError: 'Symbol' object has no attribute 'k'
Is there any possibility to equip the Symbol x with this attribute?
I already tried this workarround:
class ExtendedSymbol(sp.Symbol):
pass
x = ExtendendSymbol('x')
x.k = 0 # no problem here
However then I have the following unwanted behavior:
x2 = sp.Symbol('x')
x2 == x # -> False
Any ideas?
Best regards,
Carsten.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/5559EF9B.3090106%40gmx.de.
For more options, visit https://groups.google.com/d/optout.