Revision history [back]

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?

 3 None slelievre 14589 ●16 ●136 ●288 http://carva.org/samue...

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?