Thanks Aaron,

On 02/06/2020 00:44, Aaron Meurer wrote:
If you are using the Jupyter notebook you can run

from sympy import init_session
init_session(auto_int_to_Integer=True)

This also works in IPython in the terminal, or you can use isympy -i.
This will automatically wrap integer literals with Integer() so that
1/2 produces Integer(1)/Integer(2).
Just be aware that this could
break non-SymPy things if they don't work properly with Integer, for
example, numpy will create arrays with dtype=object when passed
Integer.



Couldn't that be made a lot more specific and therefore less risky? Looking for <integer>/<integer> and replacing it with what you describe - or indeed with Rational(<integer>,<integer>) would be a lot less likely to disturb Python code.

If the issue is only for copy-pasting, I would just use sympify() to
convert the input as a string.
Sorry, that was a typo - I mean to write Rational(3,2)!


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/e9977f6b-283b-7717-92df-a422b538b9a8%40dbailey.co.uk.

Reply via email to