Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66491 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-02-16 09:50 +1100 |
| Last post | 2014-02-16 09:50 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: passing an option to the python interpreter Chris Angelico <rosuav@gmail.com> - 2014-02-16 09:50 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-16 09:50 +1100 |
| Subject | Re: passing an option to the python interpreter |
| Message-ID | <mailman.7027.1392504640.18130.python-list@python.org> |
On Sun, Feb 16, 2014 at 9:32 AM, Jabba Laci <jabba.laci@gmail.com> wrote: > #!/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 That's a fundamental limitation with the shebang syntax: you can pass exactly one argument. Passing more than one is platform-dependent - some Unixes will pass multiple args, some will pass the whole string as a single arg (which is what you're seeing here), and I think some will discard everything from the space onward. What you could do is add a wrapper called 'pythonu'.which invokes 'env python -u %*'. Be aware, though, that shebanging to a shell script isn't safe either; modern Linuxes support it, but to be truly cross-platform, you'd have to write pythonu in a compiled language and make a binary. ChrisA
Back to top | Article view | comp.lang.python
csiph-web