On Mon, 17 Sep 2012 17:17:47 -0400, Philip Webb wrote about Re: [gentoo-user] new machine : suddenly Python 3 appears:
> 120917 Philip Webb wrote:
> > 120917 David W Noon wrote:
> >> print(' {0}'.format(eval(expression)))
>
> That works properly with Python2 in this machine ;
> I'll check it with Python3 later in the new machine.
That *is* Python 3 syntax. It is also accepted under recent releases
of Python 2.
> > 120917 Marc Joliet wrote:
> >> print(' ',eval(expression))
>
> That does the calculation, but the output is wrongly formatted :
>
> 514 bin> pycalc1 2+3
> (' ', 5)
This is because Marc's code is syntactically invalid for Python 3. It
is acceptable to Python 2, but does not do what you want; but it won't
work at all under Python 3.
It is clear that you have not taken my advice to use the -3 run-time
option in your hash-bang line. At the risk of blowing my own trumpet,
that was *extremely sound* advice; you should really take it. It would
have revealed the problems with the above code during the Python
interpreter's initial scan of the code. I'll repeat it:
!#/usr/bin/python2 -3
This will perform a Python 3 syntax check, even under Python 2. It
will identify any going-forward issues for your Python script(s).
--
Regards,
Dave [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
[email protected] (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
signature.asc
Description: PGP signature

