Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31194
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <animelovin@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; 'context': 0.05; 'cpython': 0.05; 'discard': 0.05; 'modify': 0.05; 'function,': 0.07; 'exception,': 0.09; 'expected.': 0.09; 'function:': 0.09; 'okay': 0.09; 'python:': 0.09; 'received:mail-qc0-f174.google.com': 0.09; 'cc:addr:python-list': 0.10; 'yet.': 0.13; 'clears': 0.16; 'combinations': 0.16; 'hackers': 0.16; 'oct': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'string': 0.17; 'wrote:': 0.17; 'module,': 0.17; 'changes': 0.20; 'trying': 0.21; 'combination': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'leave': 0.26; 'realize': 0.27; 'question': 0.27; 'lines': 0.28; 'rest': 0.28; 'fine': 0.28; "d'aprano": 0.29; 'readline': 0.29; 'steven': 0.29; 'us!': 0.29; 'usable': 0.29; 'url:mailman': 0.29; "i'm": 0.29; 'e.g.': 0.30; 'function': 0.30; 'helpful': 0.30; 'gets': 0.32; 'url:python': 0.32; 'not.': 0.32; 'url:listinfo': 0.32; 'club': 0.33; 'received:google.com': 0.34; 'along': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'url:org': 0.36; "i'll": 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.37; 'execute': 0.37; 'itself': 0.37; 'why': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'green': 0.38; 'some': 0.38; 'gives': 0.39; 'instead': 0.39; 'little': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'url:mail': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.62; 'received:96': 0.62; 'dont': 0.64; 'here': 0.65; 'of:': 0.65; 'realized': 0.71; 'grow': 0.74; 'yourself': 0.77; 'etienne': 0.84; 'yet?': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; bh=aMYHg9dJZLjC76C7gmNET9yx8xkmVEtyXBoAXupjSLs=; b=smncyCOWKCb5ufUqsJr9WEa4uboIiKSuXz3r77C3muW4jy99IrhWBmRlWlYVv/cKEb kuqX94Jlv60tTBe0C/kppL0BW8fYOf5XIn9zaSx+UNLWXsTt3zDRUzsVKI72nTvw75IP s/8sEa/r1rISlW/WAEfKW5rEBxxvR7wKMXpETyTjEJlcAuOvRccSiVSVzmVUUr350PQV +RmBhYmlCGcpo1CPSy/R76HW7i/CNTx6H70wLtYfS+4EkbAqOuTckkMwH6Nydm4GU0V/ LtYKT3sLxYD6WDt8W8vCLJ5RTPhzf1SxMP/u9LV6GHjLzWHnEf9O/m0SRRMi2LKQxqUo yvsw== |
| Date | Sat, 13 Oct 2012 09:44:04 -0400 |
| From | Etienne Robillard <animelovin@gmail.com> |
| To | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
| Subject | Re: readline trick needed |
| In-Reply-To | <50796ce5$0$6574$c3e8da3$5496439d@news.astraweb.com> |
| References | <50796ce5$0$6574$c3e8da3$5496439d@news.astraweb.com> |
| X-Mailer | Sylpheed 3.2.0 (GTK+ 2.24.10; i686-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Cc | 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2113.1350135833.27098.python-list@python.org> (permalink) |
| Lines | 74 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350135833 news.xs4all.nl 6955 [2001:888:2000:d::a6]:43624 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31194 |
Show key headers only | View raw
On 13 Oct 2012 13:30:14 GMT Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > I'm working with the readline module, and I'm trying to set a key > combination to process the current command line by calling a known > function, *and* enter the command line. > > Something along the lines of: > > * execute function spam() in some context where it can access > the current command line as a string > * enter the command line > > Function spam() may or may not modify the command line. > > Here is what I have got so far: I can discard the current line and call a > function: > > readline.parse_and_bind(r'"\C-p": "%cspam()\n"' % 0x15) # ^U > > binds ctrl-P to the key combinations `ctrl-U spam() Enter`, which clears > the command line before entering spam(). > > If I leave out the ctrl-U, I'll get a SyntaxError or other exception, > e.g. command line `x = 123` gets transformed into `x = 123spam()`. > > > This is not suitable: > > readline.parse_and_bind(r'"\C-p": "; spam()\n"') > > because it changes the command line. It's okay for spam() itself to > modify the command line, but the key binding should not. > > I tried to do this: > > readline.parse_and_bind(r'"\C-p": "\nspam()\n"') > > but it gives me a segmentation fault, which is a little less helpful than > I had expected. > > This Stackoverflow question suggests that what I want is not possible in > vanilla Python: > > http://stackoverflow.com/questions/11680356 > > > but I'm a stubborn guy and I have not given up yet. Any suggestions? > > > (P.S. I'm aware of IPython, I want to get this working in the standard > CPython interpreter.) > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list Why dont you grow yourself some usable neurons instead ? Don't you realize now stackoverflow.com is starting to hurt your capacity to cogitate on your own or have you not realized this yet? Cheers, Etienne -- Etienne Robillard Green Tea Hackers Club Fine Software Carpentry For The Rest Of Us! http://gthc.org/ erob@gthcfoundation.org
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
readline trick needed Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-13 13:30 +0000
Re: readline trick needed Etienne Robillard <animelovin@gmail.com> - 2012-10-13 09:44 -0400
Re: readline trick needed Chris Angelico <rosuav@gmail.com> - 2012-10-14 00:47 +1100
Re: readline trick needed Etienne Robillard <animelovin@gmail.com> - 2012-10-13 09:58 -0400
Re: readline trick needed Roel Schroeven <roel@roelschroeven.net> - 2012-10-13 23:14 +0200
Re: readline trick needed Chris Angelico <rosuav@gmail.com> - 2012-10-14 08:44 +1100
Re: readline trick needed Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-13 23:13 +0100
Re: readline trick needed Chris Angelico <rosuav@gmail.com> - 2012-10-14 09:41 +1100
Re: readline trick needed Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-13 23:52 +0100
Re: readline trick needed Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-14 01:32 +0100
[on topic] Re: readline trick needed Peter Otten <__peter__@web.de> - 2012-10-16 10:30 +0200
Re: [on topic] Re: readline trick needed Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-16 11:27 +0000
Re: [on topic] Re: readline trick needed Robert Kern <robert.kern@gmail.com> - 2012-10-16 13:20 +0100
Re: [on topic] Re: readline trick needed Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-16 12:52 +0000
Re: [on topic] Re: readline trick needed Dwight Hutto <dwightdhutto@gmail.com> - 2012-10-16 10:14 -0400
[off topic], was Re: [on topic] Re: readline trick needed Peter Otten <__peter__@web.de> - 2012-10-16 16:36 +0200
Re: [off topic], was Re: [on topic] Re: readline trick needed Dwight Hutto <dwightdhutto@gmail.com> - 2012-10-16 11:14 -0400
Re: [on topic] Re: readline trick needed Ned Deily <nad@acm.org> - 2012-10-16 01:50 -0700
Re: [on topic] Re: readline trick needed Peter Otten <__peter__@web.de> - 2012-10-16 12:20 +0200
Re: [on topic] Re: readline trick needed Ned Deily <nad@acm.org> - 2012-10-16 13:44 -0700
csiph-web