> you can also create invalid variable names, i.e. the ones starting
> with a number:
>
> sage: var('2x')
> 2x
>
> sage: 2x
> ------------------------------------------------------------
> File "<ipython console>", line 1
> 2x
> ^
> SyntaxError: invalid syntax
>
> sage: globals()['2x']
> 2x
>
> sage: type(globals()['2x'])
> <type 'sage.symbolic.expression.Expression'>
Note that this behavior is not going to last. Only valid identifiers
will be allowed in variable names. We have 2 tickets on this:
#7496 symbolic variable names should be valid identifiers
#9724 Sage allows creation of variables with empty name
The second should be closed as a duplicate. :)
Cheers,
Burcin
If you are writing code to include in .py files, then x=var('x') will
work, but var('x') will totally fail.
For purely interactive use in the notebook or command line, var('x')
is fine. But for writing programs, you should always use
x = var('x')
-- William
>
> Also, is it better to ask this kind of basic question in the Asksage
> forum or the sage-support mailing list?
>
> Thanks for your patience.
>
> --
> To post to this group, send email to sage-s...@googlegroups.com
> To unsubscribe from this group, send email to sage-support...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
>
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org