Aaron, thanks for responding to my question in detail.

On 30/06/2020 20:00, Aaron Meurer wrote:

The printer doesn't take into account your namespace. It is
copy-pastable from the point of view of having all the SymPy names
imported. We could add a string printer mode that prefixes all SymPy
names.

Thanks, I wasn't aware that print() works that way.

The problem seems to remain that if you integrate sin(x) you get cos(x), yo get a symbol cos that you didn't anticipate. Maybe integrating sin(x**3) would be a better example, where hypergeometrics and gamma functions suddenly appear in the answer - I mean these will appear without  regard to the selective importing of SymPy. Thus if you copy/paste these into an input, these will generate an undefined name error because they are not prefixed.
If you don't like using sym.cos and so on everywhere, you can just
import things directly, like

from sympy import cos

Precisely - as explained above.

I mean, is copy/paste an unusual thing to use - I would have thought it was completely normal.

I don't know Python anywhere near well enough to figure out if it is possible for print() or something else, like fullprint() to add appropriate prefixes (like sp.) to things (not just every possible prefix) as it outputs them - can it extract enough information to actually do this?

My suggestion to use "from sympy import *" within modules was meant to apply in a situation where you used a collection of modules for various purposes which all imported just SymPy. I can't quite see what the problem is in that case, unless you use Python tools.

Even without using *, it is still possible to accidentally import something from more than one module:

from sympy import sin

from numpy import sin

Indeed if you are going to use numpy in conjunction with sympy, this sort of clash seems quite inevitable unless you make all the numpy symbols work using the np. prefix.

BTW, I really do not wish to be a nuisance, because I do realise what a magnificent facility SymPy represents, and the work that must have gone into it.

David



--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ff6db073-aefc-6298-cfb3-aa0d14e8a63c%40dbailey.co.uk.

Reply via email to