Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77748
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andy.zhang@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '(first': 0.09; 'exit': 0.09; 'subject:How': 0.10; 'python': 0.11; '&&': 0.16; 'eof': 0.16; '\xc2\xa0i': 0.16; 'thanks,': 0.17; '8bit%:5': 0.22; 'input': 0.22; 'import': 0.22; 'python?': 0.22; 'shell': 0.22; 'char': 0.24; 'second': 0.26; 'function': 0.29; 'skip:p 30': 0.29; 'wonder': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'embedding': 0.31; 'null)': 0.31; 'python).': 0.31; 'file': 0.32; 'running': 0.33; 'subject:from': 0.34; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done,': 0.36; 'interact': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'should': 0.36; 'application': 0.37; 'skip:& 10': 0.38; 'to:addr:python- list': 0.38; 'skip:& 20': 0.39; 'embedded': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=TvcetANbamibd218u4ycxs/BtRhnofFxKkzN0VBRF6o=; b=ib8zqZfBYgDbz2bOl52522gaME33VFeYJcRgh1SoAoZoQB3fFLG16IVrgUjgDt+3tz EvOy5EEg1+CCE63Xy547tARMREDaF/OngMGJPOiKV4zVQMmwoPUKAndAgA8FLZPvG2lk Q9SE4eEKd0/lU634/ir0OrUCDzXC/rgoD8VCWd8Ykg9pplp2MIRJDS0qKr4xubgagppf ew5RnFuDJvgPiY6tLPI8STIISoe82/wPFPwDY2/bKlhiJMLZigG0fB7i1+0nStF3F81G hlzZRPZ3uJoyurAUcoo8ROtRJ36HupNYPq3Z0GXPwCVWJXJufj4aPY3LNsZ7+PP0juqu d0yA== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.202.106 with SMTP id kh10mr35480969lbc.66.1410285430498; Tue, 09 Sep 2014 10:57:10 -0700 (PDT) |
| Date | Tue, 9 Sep 2014 13:57:10 -0400 |
| Subject | How to exit from embedded IPython shell? |
| From | Andy Zhang <andy.zhang@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=001a11c36a241def6f0502a5aa5a |
| 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.13913.1410285433.18130.python-list@python.org> (permalink) |
| Lines | 64 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1410285433 news.xs4all.nl 2899 [2001:888:2000:d::a6]:60343 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77748 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi,
I am embedding IPython inside a c application, by running PYTHONSTARTUP
file which is:
import IPython
IPython.embed()
Then the application interact with user input via stdin. After the user is
done, she would type EOF. The program should exit, but keep all the python
objects in memory, and the user can re-enter python by calling the function
again.
Because of the embedded IPython, the user needs to enter EOF twice (First
EOF exit IPython, second exit outter Python). I wonder whether it is
possible to exit the outer Shell in my C code so that user can type one EOF
and exit IPython and Python?
char *startup = Py_GETENV("PYTHONSTARTUP");
if (startup != NULL && startup[0] != '\0') {
FILE *fp = fopen(startup, "r");
if (fp != NULL) {
(void) PyRun_SimpleFile(fp, startup);
PyErr_Clear();
fclose(fp);
}
}
retval = PyRun_AnyFile(stdin, (const char *) "<stdin>");
Many thanks,
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
How to exit from embedded IPython shell? Andy Zhang <andy.zhang@gmail.com> - 2014-09-09 13:57 -0400
csiph-web