Reputation: 121
The sympy gives out the results like:
Ellipse(Point(0,0),3,2)
Point(2.875, -0.661437827706861)
If I want to pick up these numbers: 0,0,3,2,2.875... Any simple way to get them?
Upvotes: 2
Views: 39
Reputation: 19037
If you just want the numbers you can get them with atoms(Number):
>>> Point(2.875, -0.661437827706861).atoms(Number)
set([-661437827706861/1000000000000000, 23/8])
>>> Ellipse(Point(0, 0), 3, 2).atoms(Number)
set([0, 2, 3])
>>> Tuple(Point(2.875, -0.661437827706861), Ellipse(Point(0, 0), 3, 2)).atoms(
... Number)
set([0, 2, 3, -661437827706861/1000000000000000, 23/8])
Upvotes: 1
Reputation: 56644
>>> from sympy import Ellipse, Point
>>> e = Ellipse(Point(0, 0), 3, 2)
>>> p, maj, min_ = e.args
>>> maj
3
>>> p
Point(0, 0)
>>> x, y = p.args
>>> x
0
Upvotes: 2