The easiest way to figure this out is to see what the type of the object is.
In [1]: a = Plot(0) In [2]: a Out[2]: [0]: 0, 'mode=cartesian' In [3]: type(a) Out[3]: <class 'sympy.plotting.plot.Plot'> Here, we see that the class is in sympy.plotting.plot. Unfortunately, it is not the same as the Plot used above, which is just a function: In [6]: type(Plot) Out[6]: <type 'function'> So we import it as a different name to avoid overriding the Plot function: In [8]: from sympy.plotting.plot import Plot as PlotClass In [9]: PlotClass Out[9]: <class 'sympy.plotting.plot.Plot'> In [11]: isinstance(a, PlotClass) Out[11]: True On Mon, Jul 18, 2011 at 4:44 PM, Sam Magura <[email protected]> wrote: > I need to test to see if an object is a sympy.plotting.plot.Plot - i.e. Plot > object, but I'm running in to trouble. > What I want to do: >>>> myPlot = Plot(0) >>>> isinstance(myPlot, something) > True > Issues I'm having: >>>> import sympy >>>> sympy.plot > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'module' object has no attribute 'plot' >>>> sympy.Plot > <function Plot at 0x8c00f44> >>>> sympy.plotting > <module 'sympy.plotting' from 'sympy/plotting/__init__.pyc'> >>>> sympy.plotting.plot > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'module' object has no attribute 'plot' >>>> import sympy.plotting.plot > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "sympy/plotting/plot.py", line 10, in <module> > raise ImportError("pyglet is required for plotting.\n visit > http://www.pyglet.org/") > ImportError: pyglet is required for plotting. > visit http://www.pyglet.org/ By the way, this error is misleading because there is a bare except converting all errors into this one. See https://github.com/sympy/sympy/pull/497. Aaron Meurer > > Thanks. > -- 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.
