Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73314
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'assuming': 0.09; 'prefix': 0.09; 'subject:skip:t 10': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'windows': 0.15; '-tkc': 0.16; 'differs': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'operation,': 0.16; 'string:': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'split': 0.19; 'cc:addr:python.org': 0.22; 'error': 0.23; 'byte': 0.24; 'case.': 0.24; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'pass': 0.26; 'header :In-Reply-To:1': 0.27; 'chris': 0.29; 'skip:p 30': 0.29; 'skip:s 30': 0.35; 'charset:us-ascii': 0.36; 'list': 0.37; '(i.e.,': 0.38; 'most': 0.60; 'free': 0.61; 'back': 0.62; "you'll": 0.62; 'to:addr:gmail.com': 0.65; 'incorporate': 0.68; 'behavior': 0.77; "it'd": 0.84; 'received:50.22': 0.84; 'wish.': 0.84 |
| Date | Mon, 16 Jun 2014 05:51:24 -0500 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Subject | Re: line to argv transformation |
| In-Reply-To | <CAPTjJmq3632=BXUYmd-EEUtaKAVj=pQQ2m-uz_Fd_PoQT1agQg@mail.gmail.com> |
| References | <539EBF61.4050106@rece.vub.ac.be> <CAPTjJmqd74v013WwG2QrZP2y9N+gMk0TK5xT5-yy3=8gOuAs4g@mail.gmail.com> <539EC5EF.7040205@rece.vub.ac.be> <CAPTjJmq3632=BXUYmd-EEUtaKAVj=pQQ2m-uz_Fd_PoQT1agQg@mail.gmail.com> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| X-Get-Message-Sender-Via | boston.accountservergroup.com: authenticated_id: tim@thechases.com |
| Cc | "python-list@python.org" <python-list@python.org> |
| 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.11085.1402917709.18130.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402917709 news.xs4all.nl 2976 [2001:888:2000:d::a6]:36895 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:73314 |
Show key headers only | View raw
On 2014-06-16 20:41, Chris Angelico wrote:
> Oops! I made the cardinal error of trying in one and assuming it'd
> work in both. Just needs a b prefix on the split string:
>
> def shell_split(cmd):
> return subprocess.check_output("""python -c 'import sys;
> print("\\0".join(sys.argv[1:]))'
> """+cmd,shell=True)[:-1].split(b"\0")
>
> You'll get back a list of byte strings, in any case. Feel free to
> pass them through a decode operation, or to incorporate a .decode()
> into the above stream, as you wish.
Tested on Win32? The behavior of "shell expansion" on Windows
cmd.exe differs from most *nix shells (i.e., it *doesn't* expand, so
you have to do it yourself), so Antoon would need to describe the
desired behavior on Win32.
-tkc
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: line to argv transformation Tim Chase <python.list@tim.thechases.com> - 2014-06-16 05:51 -0500
csiph-web