Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to break up function definitions accross several lines?

if i write a function definition and i break it up across several lines, the sage prepocessor complains:

phi(epsilon, Q, r) = 1/(4*pi*
                        epsilon
)*Q/r

show(phi(1,2,3))

the sage prepocessor complains:

sage demo.sage
  File "demo.sage.py", line 6
    __tmp__=var("epsilon,Q,r"); phi = symbolic_expression(_sage_const_1 /(_sage_const_4 *pi*).function(epsilon,Q,r)
                                                                                            ^
SyntaxError: invalid syntax

While this is a very short function that is easily kept on one line, I do have rather long and intricate ones which I would like to break up (and potentially comment) over several lines.

How do I do that?

how to break up function definitions accross several lines?

if i write a function definition and i break it up across several lines, the sage prepocessor complains:

phi(epsilon, Q, r) = 1/(4*pi*
                        epsilon
)*Q/r

show(phi(1,2,3))

the sage prepocessor complains:

sage demo.sage
  File "demo.sage.py", line 6
    __tmp__=var("epsilon,Q,r"); phi = symbolic_expression(_sage_const_1 /(_sage_const_4 *pi*).function(epsilon,Q,r)
                                                                                            ^
SyntaxError: invalid syntax

While this is a very short function that is easily kept on one line, I do have rather long and intricate ones which I would like to break up (and potentially comment) over several lines.

Linebreaks with backslash as the last char of the line don't work:

cat demo.sage
phi(epsilon, Q, r) = 1/(4*pi*\
                        epsilon\
)*Q/r

show(phi(1,2,3))

% sage demo.sage
  File "demo.sage.py", line 6
    __tmp__=var("epsilon,Q,r"); phi = symbolic_expression(_sage_const_1 /(_sage_const_4 *pi* * BackslashOperator() * ).function(epsilon,Q,r)
                                                                                             ^
SyntaxError: invalid syntax

How do I do that?

how to break up function definitions accross several lines?

if i write a function definition and i break it up across several lines, the sage prepocessor complains:

phi(epsilon, Q, r) = 1/(4*pi*
                        epsilon
)*Q/r

show(phi(1,2,3))

the sage prepocessor complains:

sage demo.sage
  File "demo.sage.py", line 6
    __tmp__=var("epsilon,Q,r"); phi = symbolic_expression(_sage_const_1 /(_sage_const_4 *pi*).function(epsilon,Q,r)
                                                                                            ^
SyntaxError: invalid syntax

While this is a very short function that is easily kept on one line, I do have rather long and intricate ones which I would like to break up (and potentially comment) over several lines.

Linebreaks with backslash as the last char of the line don't work:

cat demo.sage
phi(epsilon, Q, r) = 1/(4*pi*\
                        epsilon\
)*Q/r

show(phi(1,2,3))

% sage demo.sage
  File "demo.sage.py", line 6
    __tmp__=var("epsilon,Q,r"); phi = symbolic_expression(_sage_const_1 /(_sage_const_4 *pi* * BackslashOperator() * ).function(epsilon,Q,r)
                                                                                             ^
SyntaxError: invalid syntax

How do I do that?