Hello,

On Tue, Jul 17, 2012 at 1:18 PM, [email protected]
<[email protected]> wrote:
> In the diffgeom module there are classes that may have the same names
> as classes in other namespaces:
>
> - Point
> - Differential
> - Commutator
>
> How to implement printing for such classes? I can just override the
> _print methods of the classes instead of rely on the methods of the
> Printer classes. It is an ugly solution. Other ideas?

The problem you describe seems to be sufficiently generic.  Perhaps
you could extend Printer._print to check the __module__ attribute of
the class of the expression and see if there are _print methods which
include both the namespace and the class name before other checks.
You may want to look at test_args to directly crop out the class name
mangling functionality.

Perhaps, in view of the possibility of the situations you describe,
resolution by class name only could just be removed from Printer,
forcing everyone who adds a new printable class to provide a properly
qualified name for the printing function.  I don't know if anyone has
the time to implement that change right now, though.

Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to