1 |
120917 Neil Bothwick wrote: |
2 |
> On Sun, 16 Sep 2012 20:24:01 -0400, Philip Webb wrote: |
3 |
>> We've been warned not to use Python 3 , so it's not installed in this |
4 |
>> box, but it was included along with Python 2 in the Stage3 for the new |
5 |
>> machine. I now find that 13 pkgs have been compiled relying on it |
6 |
>> & Portage refuses to unmerge it. Is this safe ? |
7 |
> Perfectly safe, because we weren't warned to not use it, |
8 |
> only to not set it as the default. That is reasonable |
9 |
> because older scripts aren't aware of the differences between Python 2/3, |
10 |
> while newer scripts can explicitly call whichever version they need. |
11 |
> The only problem with setting Python 3 as the default |
12 |
> is that some older scripts may break. |
13 |
|
14 |
I discovered this because my little script to do CLI calculations |
15 |
-- by far the fastest of anything, if you don't need variables -- |
16 |
wouldn't work in the new machine till I did s/python/python2 . |
17 |
|
18 |
In case others might like to use it, the script is : |
19 |
|
20 |
#!/usr/bin/python2 |
21 |
from math import * |
22 |
import sys |
23 |
expression = sys.argv[1] |
24 |
print ' ',eval(expression) |
25 |
|
26 |
Its help is via 'pydoc math'. Expressions need quotes if they have brackets. |
27 |
|
28 |
It was failing with a syntax error in the print line, |
29 |
when the 1st line read #!/usr/bin/python , |
30 |
so I have to assume (1) that Python3 has been set as default |
31 |
-- No ! I didn't do it ! -- & (2) its syntax for printing has changed. |
32 |
|
33 |
Thanks for the polite explanation. Further comments welcome. |
34 |
|
35 |
-- |
36 |
========================,,============================================ |
37 |
SUPPORT ___________//___, Philip Webb |
38 |
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto |
39 |
TRANSIT `-O----------O---' purslowatchassdotutorontodotca |