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


Groups > comp.lang.python > #66491

Re: passing an option to the python interpreter

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'discard': 0.07; 'error:': 0.07; 'problem?': 0.07; 'string': 0.09; 'skip:/ 10': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"python': 0.16; 'arg': 0.16; 'args,': 0.16; 'argument.': 0.16; 'binary.': 0.16; 'either;': 0.16; 'exist.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'invokes': 0.16; 'subject:python': 0.16; 'language': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'command': 0.22; 'feb': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'compiled': 0.26; 'pass': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; "skip:' 10": 0.31; 'file': 0.32; 'run': 0.32; 'limitation': 0.33; 'skip:# 10': 0.33; 'subject:the': 0.34; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'skip:. 10': 0.39; 'though,': 0.39; 'called': 0.40; 'space': 0.40; 'how': 0.40; 'truly': 0.60; "you're": 0.61; 'such': 0.63; 'more': 0.64; 'safe': 0.72; 'overcome': 0.74; 'env': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=VWIzuZS2cuz9n0+A+Dq51lsrku9wF4KXadb/kBQ7xv4=; b=zKUN1MuTmb6GOfJwEQlf3yqRkQ2f1gqAbKXFTyGpFefKF+SUy/hGQSf7UHyZ8wL14a 7QpvI6FtDK+Q8WNAQizwunHp3wbQfj/q5Qe4Nocv7eXsYhcNLpw4Y8zziJBJiGRfRh/N SGVE81q0QzFp0gPYsYuPknC36GiYFKoOaB8uDpMZiI6d3qiSwHJtE9qW2ptuq0r7w1no 8nYCruwpxVPZn/y7lFrY7+DM9DpxS9UxkKeJ4Rxk1MkEpyFx8bw6+fxaDe+YKuwWJ4Kq XIlE+KTgWZtF05RX+MSXN5V/DNXFFPG/f9E/VzW215kG1Iv5XeJ/EJ1LJrWUPS8WR2yx hw/g==
MIME-Version 1.0
X-Received by 10.66.118.71 with SMTP id kk7mr17257685pab.14.1392504636934; Sat, 15 Feb 2014 14:50:36 -0800 (PST)
In-Reply-To <CAOuJsMmwOAatTO7Hsx3eYDoo31D81rBJBfnYb6Me-Z09EjORcw@mail.gmail.com>
References <CAOuJsMmwOAatTO7Hsx3eYDoo31D81rBJBfnYb6Me-Z09EjORcw@mail.gmail.com>
Date Sun, 16 Feb 2014 09:50:36 +1100
Subject Re: passing an option to the python interpreter
From Chris Angelico <rosuav@gmail.com>
Cc Python mailing list <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7027.1392504640.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392504640 news.xs4all.nl 2829 [2001:888:2000:d::a6]:45076
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66491

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: passing an option to the python interpreter Chris Angelico <rosuav@gmail.com> - 2014-02-16 09:50 +1100

csiph-web