Hi,
On 4 July 2011 20:33, Adam Moore <[email protected]> wrote:
> So when I import x from sympy.abc, and then check its 'type', its type
> is <class 'sympy.core.symbol.Symbol'>
>
> What makes this so? In a project I'm working on, I'm trying to learn
> some lessons from sympy as to how variables and such are handled, but
> when I create my own Symbol class and execute
>
> x = Symbol('x')
>
> and then check the type, its type is <type 'instance'>
>
> What is the nature of a Symbol in sympy then if it is not also an
> instance of a class?
>
Can you show a complete code sample? I get the following:
$ ipython
In [1]: from sympy import *
In [2]: x = Symbol('x')
In [3]: type(x)
Out[3]: <class 'sympy.core.symbol.Symbol'>
In [4]: del x
In [5]: from sympy.abc import x
In [6]: type(x)
Out[6]: <class 'sympy.core.symbol.Symbol'>
The abc module just uses Symbol():
In [7]: from sympy import abc
In [8]: abc??
Type: module
Base Class: <type 'module'>
String Form: <module 'sympy.abc' from 'sympy/abc.pyc'>
Namespace: Interactive
File: /home/matt/repo/git/sympy/sympy/abc.py
Source:
from core import Symbol
_latin = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
# COSINEQ should not be imported as they clash; gamma, pi and zeta clash,
too
_greek = 'alpha beta gamma delta epsilon zeta eta theta iota kappa '\
'mu nu xi omicron pi rho sigma tau upsilon phi chi psi omega'.split(' ')
for _s in _latin + _greek:
exec "%s = Symbol('%s')" % (_s, _s)
del _latin, _greek, _s
But anyway, in both cases x is an instance of Symbol class.
>
> -Adam
>
> --
> 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.
>
>
Mateusz
--
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.