version
Paul Moore
p.f.moore at gmail.com
Sat Jun 2 05:16:07 EDT 2018
On 2 June 2018 at 02:34, Mike McClain <mike.junk.46 at att.net> wrote:
> It looks like what I was wanting is something like 'C's #if, a
> compiler conditional.
>
> Does python have anything like that to tell the interpreter to ignore
> a line that is not a comment or a quoted string?
No, it doesn't.
Honestly, if you are writing "play" scripts as you say, I wouldn't
bother trying to make them cross-version compatible. Move all your old
scripts to a "python2" subdirectory and forget them. Write new scripts
as Python 3 only. As an exercise in understanding the differences
between Python 2 and 3, porting some of the scripts in your "python2"
directory to Python 3 would possibly be a useful thing to do.
If you have important scripts that you use a lot that are in Python 2
form, continue running them under Python 2 until you have some time
(and maybe the understanding, if they are complex) to port them, and
then switch.
Paul
More information about the Python-list
mailing list