Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

var("x,y,z") :

  • creates the Sage objects representing the symbolic variables called $x$, $y$ an,d $z$,

  • attachs them to the Python variables x, y and z, and

  • returns them as a tuple).

The difference is that x, y, z = var("x, y, z") re-affects the elepents of the tuple to the Python variables x, y and z, which is pretty unuseful but forbids the Python interpreter to print them.

A potentially more useful use would be to affect the tuple to another Python variable representing them collectively. See my answer to this question for an example.

var("x,y,z") :

  • creates the Sage objects representing the symbolic variables called $x$, $y$ an,d $z$,

  • attachs them to the Python variables x, y and z, and

  • returns them as a tuple).

The difference is that x, y, z = var("x, y, z") re-affects the elepents elements of the tuple to the Python variables x, y and z, which is pretty unuseful but forbids the Python interpreter to print them.

A potentially more useful use would be to affect the tuple to another Python variable representing them collectively. See my answer to this question for an example.

var("x,y,z") :

  • creates the Sage objects representing the symbolic variables called $x$, $y$ an,d $z$,

  • attachs them to the Python variables x, y and z, and

  • returns them as (as a tuple).

The difference is that x, y, z = var("x, y, z") re-affects the elements of the tuple to the Python variables x, y and z, which is pretty unuseful but forbids the Python interpreter to print them.

The homonymy between symbolic variable names and the names pf the Python variables pointing to them is often quite useful. A great way to confuse oneself (read : to shoot oneself in the foot) is to break it ; for example, it would be legal to write y, z, x=var("x, y, z") ; this can happen in successive "improvements" to a portion of code (don't ask me how I know it... ;-).

A potentially more useful use would be to affect the tuple to another Python variable representing them collectively. See my answer to this question for an (useful) example.