cls is the class that is being instantiated. It will usually be
Symbol, but if something subclasses Symbol, it will be that instead.
It is similar to self, except self is usually used for instances, not
classes.

Zero is the SymPy version of 0. If you type "0", that gives the Python
int(0). Zero prints as 0, and any time you combine another SymPy
operation with 0, it gets transformed to 0 (via sympify()). The
"Advanced Expression Manipulation" section of the tutorial explains
this in more detail.

Aaron Meurer



On Fri, May 16, 2014 at 7:52 PM, Abhishek K Das
<[email protected]> wrote:
> Along with this I needed to ask one more thing as for the definition of
> class Zero , there are methods where S.Zero is returned . Has the word Zero
> been hardcoded to 0 somewhere because
> I don't understand how that returns value 0 . Similarly is the case with
> `One` also .
>
>
> On Saturday, May 17, 2014 6:50:45 AM UTC+5:30, Abhishek K Das wrote:
>>
>>     def __new__(cls, name, **assumptions):
>>         """Symbols are identified by name and assumptions::
>>
>>
>>         >>> from sympy import Symbol
>>         >>> Symbol("x") == Symbol("x")
>>         True
>>         >>> Symbol("x", real=True) == Symbol("x", real=False)
>>         False
>>
>>
>>         """
>>
>>
>>         if assumptions.get('zero', False):
>>             return S.Zero
>>         is_commutative = fuzzy_bool(assumptions.get('commutative', True))
>>         if is_commutative is None:
>>             raise ValueError(
>>                 '''Symbol commutativity must be True or False.''')
>>
>> I was studying how declaration of Symbol works with the help of winpdb .
>> `name` is for the name of symbol and `assumptions` are the assumptions
>> associated with it .
>> What about the cls variable , I didn't understand it's use and what does
>> assumptions.get('zero',False) mean ?
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/52ea2793-3c7b-43ba-a816-02dd1f804c65%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BwkQB2RSnvSzKEMzAajCJFB52xhsB_egXXNo7O4v1r%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to