Shebang line on Windows?

MRAB python at mrabarnett.plus.com
Fri Feb 22 18:21:12 EST 2013


On 2013-02-22 22:53, James Harris wrote:
> On Feb 22, 6:40 pm, Zachary Ware <zachary.ware+pyl... at gmail.com>
> wrote:
>
>> On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry <walterhu... at lavabit.com> wrote:
>
>> > I use FreeBSD or Linux, but my son is learning Python and is using
>> > Windows.
>>
>> > My question is this: Would it be good practice for him to put #!/usr/bin/
>> > env python at the top of his scripts, so that if made executable on *nix
>> > they will be OK? As I understand it this will have no effect on Windows
>> > itself.
>>
>> Adding the shebang line on Windows would be excellent practice.
>
> A word of warning unless this has since been resolved: Whenever I have
> tried adding the shebang line on Windows and running it on Unix the
> latter has complained about the carriage return at the end of the
> line. This means that Unix does not work when invoked as follows.
> (And, yes, the file has had chmod +x applied.)
>
>    ./program.py
>
> It is, of course, OK when run as
>
>    python program.py
>
> but that removes some of the benefit of the shebang line.
>
Just use Unix line endings. Python will accept them, and any decent editor
on Windows will accept them. (Notepad doesn't.)




More information about the Python-list mailing list