passing an option to the python interpreter

J

Jabba Laci

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
 
M

Marko Rauhamaa

Jabba Laci said:
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
 
A

Anssi Saari

Marko Rauhamaa said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top