Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66488 > unrolled thread

passing an option to the python interpreter

Started byJabba Laci <jabba.laci@gmail.com>
First post2014-02-15 23:32 +0100
Last post2014-03-02 21:40 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  passing an option to the python interpreter Jabba Laci <jabba.laci@gmail.com> - 2014-02-15 23:32 +0100
    Re: passing an option to the python interpreter Marko Rauhamaa <marko@pacujo.net> - 2014-02-16 00:47 +0200
      Re: passing an option to the python interpreter Anssi Saari <as@sci.fi> - 2014-03-02 21:40 +0200

#66488 — passing an option to the python interpreter

FromJabba Laci <jabba.laci@gmail.com>
Date2014-02-15 23:32 +0100
Subjectpassing an option to the python interpreter
Message-ID<mailman.7026.1392503602.18130.python-list@python.org>
Hi,

The first line in my scripts looks like this:

#!/usr/bin/env python

I would like to use unbuffered output in a script, which can be done
with the -u option, thus I tried this:

#!/usr/bin/env python -u

But if I want to run it from the command line ($ ./unbuffered.py), I
get this error:

/usr/bin/env: python -u: No such file or directory

env is looking for "python -u" but such a command doesn't exist.

How to overcome this problem? I could write

#!/usr/bin/python -u

but I prefer to call python through env. For instance if I put this
last one in a virtualenv, that would call the system-wide interpreter
not the one in the virtualenv.

Thanks,

Laszlo

[toc] | [next] | [standalone]


#66490

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-02-16 00:47 +0200
Message-ID<871tz4kn6p.fsf@elektro.pacujo.net>
In reply to#66488
Jabba Laci <jabba.laci@gmail.com>:

> I tried this:
>
> #!/usr/bin/env python -u

The hash-bang notation is quite rigid; it only accepts a single argument
("python") to the command ("/usr/bin/env").

I don't know if there is a simple workaround.


Marko

[toc] | [prev] | [next] | [standalone]


#67464

FromAnssi Saari <as@sci.fi>
Date2014-03-02 21:40 +0200
Message-ID<vg3a9d8wfr5.fsf@coffee.modeemi.fi>
In reply to#66490
Marko Rauhamaa <marko@pacujo.net> writes:

> Jabba Laci <jabba.laci@gmail.com>:
>
>> I tried this:
>>
>> #!/usr/bin/env python -u
>
> The hash-bang notation is quite rigid; it only accepts a single argument
> ("python") to the command ("/usr/bin/env").
>
> I don't know if there is a simple workaround.

Using the relevant environment variable (PYTHONUNBUFFERED) seems simple
to me.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web