running python 2 vs 3

Chris Angelico rosuav at gmail.com
Thu Mar 20 13:30:58 EDT 2014


On Fri, Mar 21, 2014 at 4:10 AM, notbob <notbob at nothome.com> wrote:
> On 2014-03-20, Zachary Ware <zachary.ware+pylist at gmail.com> wrote:
>
>> If you're specifying the interpreter in your command (by calling
>> "python <scriptname>.py", etc), the shebang won't mean anything
>> anyway.
>
> DOH!
>
> I was following you, fine, until that last sentence.  Then how should
> I invoke the scripts? ....as your example is exactly how I've been
> doing it with 2.7, as per Learn Python the Hard Way.  Simply
> ./<scriptname>.py from the appropriate directory (assuming I keep both
> vers in separate dirs)?

That's a fine way to do it. Zachary is mentioning an alternative, and
showing that the shebang doesn't hurt (it's a comment to Python), so
go ahead and put the shebang in all your scripts.

ChrisA



More information about the Python-list mailing list