120917 David W Noon wrote:
> On Mon, 17 Sep 2012 14:45:41 -0400, Philip Webb asked about
>> print ' ',eval(expression)
>> whose syntax is obsolete in Python3.
> print(' {0}'.format(eval(expression)))
> be aware that the above is only for your original print statement.
> There are a myriad of new formatting options that address
> various other configurations of the old print statement
> and the above does not cover anything like all of them.
Thanks : someone else suggested a different format below.
It doesn't matter today, but perhaps Python2 will disappear sometime.
>> how to get Python3 started from CLI automatically to load the math
>> item ? -- ie to do 'from math import *' without my having to type it ?
> You can't. It is program code and you have to code it yourself.
> If your Python variable "expression" contains an arithmetic expression,
> you might be able to get the shell to evaluate it for you,
> but shells do not normally do logs, trig or other transcendental functions.
Yes, that's why I use my script, which does all the everyday jobs.
120917 Marc Joliet wrote:
> print ' ',eval(expression)
> becomes
> print(' ',eval(expression))
Thanks for that version too (smile).
The one limitation of the script is that it doesn't allow variables ;
you can easily recall previous lines via Bash & mouseover+drop bits,
but AFAIK there's no way to assign values to variables.
With Python running as interpreter, I would get much more capability,
but I would need to enter the special line to load the math functions :
is it possible to do it with some capitalised variable in .bashrc ,
which might list parameters telling Python3 what to load when it starts ?
one of the 'man' files seems to refer to something like that, but briefly.
--
========================,,============================================
SUPPORT ___________//___, Philip Webb
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
TRANSIT `-O----------O---' purslowatchassdotutorontodotca