I would recommend use the star import for interactive CAS  work, otherwise 
I would second Aaron in using

    import sympy as sym

On Monday, June 29, 2020 at 3:43:14 PM UTC-5, David Bailey wrote:
>
> On 29/06/2020 17:16, Oscar Benjamin wrote:
>
>
> In any significant codebase star-import is a bad idea. It makes it
> hard to trace the origin of an imported name when looking at the code.
> If I'm looking at the code and I see sp.cos then I expect that sp will
> be defined or imported somewhere at the top of the file and I can just
> go to the first occurrence of it in the file to see where it comes
> from. Likewise if you use "from sympy import cos" and I see cos(2) I
> expect that cos will be imported at the top and I can search for that.
>
>
> I feel there are some good reasons to star import SymPy (which is why this 
> subject keeps coming up) these reasons tend to get downplayed. One is the 
> obvious fact that complicated algebraic equations just don't look nice with 
> sp. prefixing functions like cos(). Another is the fact that I would guess 
> many users only intend to use SymPy even though their code is complicated - 
> not really throw away one-off code. Such users are, in effect, using Sympy 
> as an algebra processing system, and are not interested in Python, though 
> they might want to import their own modules that also star imported SymPy.
>
> SymPy's 750000 lines of code is obviously an extreme case.
>
> There also seems to be a certain inconsistency associated with importing 
> SymPy symbols selectively (tested using 1.6):
>
> import sympy
> from sympy import integrate
> from sympy import sin
> x=sympy.symbols('x')
>
> integrate(sin(x),x)
>
> Returns
>
> -cos(x)
>
> I would have expected -sympy.cos(x), and indeed if you subsequently enter 
> cos(x), you get a name error because cos is not defined!
>
>
>
You can import something like

    from sympy import sin, cos, tan, exp

so you don't have this kind of problem.

-- 
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/d513ba73-79a3-4142-9021-46a9f8a91a43o%40googlegroups.com.

Reply via email to