Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62337 > unrolled thread
| Started by | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| First post | 2013-12-18 12:17 -0800 |
| Last post | 2013-12-19 07:33 +0000 |
| Articles | 9 — 6 participants |
Back to article view | Back to comp.lang.python
how to develop code using a mix of an existing python-program and console-commands Jean Dubois <jeandubois314@gmail.com> - 2013-12-18 12:17 -0800
Re: how to develop code using a mix of an existing python-program and console-commands Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-18 15:25 -0500
Re: how to develop code using a mix of an existing python-program and console-commands Jerry Hill <malaclypse2@gmail.com> - 2013-12-18 15:28 -0500
Re: how to develop code using a mix of an existing python-program and console-commands Jean Dubois <jeandubois314@gmail.com> - 2013-12-18 19:16 -0800
Re: how to develop code using a mix of an existing python-program and console-commands Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-18 15:29 -0500
Re: how to develop code using a mix of an existing python-program and console-commands Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-18 20:52 +0000
Re: how to develop code using a mix of an existing python-program and console-commands Terry Reedy <tjreedy@udel.edu> - 2013-12-18 17:02 -0500
Re: how to develop code using a mix of an existing python-program and console-commands Christian Gollwitzer <auriocus@gmx.de> - 2013-12-19 08:24 +0100
Re: how to develop code using a mix of an existing python-program and console-commands Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-19 07:33 +0000
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-18 12:17 -0800 |
| Subject | how to develop code using a mix of an existing python-program and console-commands |
| Message-ID | <7fb59330-6de2-4ea9-923e-7845de22df1e@googlegroups.com> |
I have a python-program which I want to perform its task first, then switch to the python console to experiment with further commands, using what was already defined in the python-program. I want this as an alternative for what I do now (but which is not very efficient): I start the python-console and then manually copy-paste line per line from the program in the console, then try out possible continuation commands, if however something goes wrong I have to redo the whole process. any suggestions? thanks in advance jean
[toc] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-12-18 15:25 -0500 |
| Message-ID | <mailman.4382.1387398324.18130.python-list@python.org> |
| In reply to | #62337 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Dec 18, 2013 at 3:17 PM, Jean Dubois <jeandubois314@gmail.com>wrote: > I have a python-program which I want to perform its task first, then > switch to > the python console to experiment with further commands, using what was > already > defined in the python-program. > I want this as an alternative for what I do now (but which is not very > efficient): > I start the python-console and then manually copy-paste line per line from > the program in the console, then try out possible continuation commands, > if however something goes wrong I have to redo the whole process. > > any suggestions? > thanks in advance > jean > -- > https://mail.python.org/mailman/listinfo/python-list > Write the code to a file. you can run it like: python program_name.py Go back to your text editor and do copy all (ctl-a, ctl-v) then open a python console and paste it in -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Jerry Hill <malaclypse2@gmail.com> |
|---|---|
| Date | 2013-12-18 15:28 -0500 |
| Message-ID | <mailman.4383.1387398496.18130.python-list@python.org> |
| In reply to | #62337 |
On Wed, Dec 18, 2013 at 3:17 PM, Jean Dubois <jeandubois314@gmail.com> wrote: > I have a python-program which I want to perform its task first, then > switch to > the python console to experiment with further commands, using what was > already > defined in the python-program. > I want this as an alternative for what I do now (but which is not very > efficient): > I start the python-console and then manually copy-paste line per line from > the program in the console, then try out possible continuation commands, > if however something goes wrong I have to redo the whole process. On the command line, python itself can take command line options, including one that does exactly what you're looking for. python -i script.py That command will run script.py to its end, then drop you into the interactive interpreter with the environment intact from running the script. -- Jerry
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-18 19:16 -0800 |
| Message-ID | <b2666f74-e2f4-4889-b68e-4b09621f456e@googlegroups.com> |
| In reply to | #62339 |
Op woensdag 18 december 2013 21:28:05 UTC+1 schreef Jerry Hill: > On Wed, Dec 18, 2013 at 3:17 PM, Jean Dubois <jeandubois314@gmail.com> wrote: > > I have a python-program which I want to perform its task first, then > > switch to > > the python console to experiment with further commands, using what was > > already > > defined in the python-program. > > I want this as an alternative for what I do now (but which is not very > > efficient): > > I start the python-console and then manually copy-paste line per line from > > the program in the console, then try out possible continuation commands, > > if however something goes wrong I have to redo the whole process. > On the command line, python itself can take command line options, > including one that does exactly what you're looking for. > python -i script.py > That command will run script.py to its end, then drop you into the > interactive interpreter with the environment intact from running the > script. Thank you very much Jerry, this is exactly what I needed kind regards, jean
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-12-18 15:29 -0500 |
| Message-ID | <mailman.4384.1387398588.18130.python-list@python.org> |
| In reply to | #62337 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Dec 18, 2013 at 3:28 PM, Jerry Hill <malaclypse2@gmail.com> wrote: > On Wed, Dec 18, 2013 at 3:17 PM, Jean Dubois <jeandubois314@gmail.com> > wrote: > > I have a python-program which I want to perform its task first, then > > switch to > > the python console to experiment with further commands, using what was > > already > > defined in the python-program. > > I want this as an alternative for what I do now (but which is not very > > efficient): > > I start the python-console and then manually copy-paste line per line > from > > the program in the console, then try out possible continuation commands, > > if however something goes wrong I have to redo the whole process. > > On the command line, python itself can take command line options, > including one that does exactly what you're looking for. > > python -i script.py > > That command will run script.py to its end, then drop you into the > interactive interpreter with the environment intact from running the > script. > > -- > Jerry > -- > https://mail.python.org/mailman/listinfo/python-list > Wow, Jerry, I didn't know that one. Cool -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-18 20:52 +0000 |
| Message-ID | <mailman.4386.1387399972.18130.python-list@python.org> |
| In reply to | #62337 |
On 18/12/2013 20:17, Jean Dubois wrote: > I have a python-program which I want to perform its task first, then > switch to > the python console to experiment with further commands, using what was > already > defined in the python-program. > I want this as an alternative for what I do now (but which is not very > efficient): > I start the python-console and then manually copy-paste line per line from > the program in the console, then try out possible continuation commands, > if however something goes wrong I have to redo the whole process. > > any suggestions? > thanks in advance > jean > An alternative to the excellent answer from Jerry Hill is to use the iPython %paste command. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-12-18 17:02 -0500 |
| Message-ID | <mailman.4388.1387404183.18130.python-list@python.org> |
| In reply to | #62337 |
On 12/18/2013 3:28 PM, Jerry Hill wrote: > On Wed, Dec 18, 2013 at 3:17 PM, Jean Dubois <jeandubois314@gmail.com> wrote: >> I have a python-program which I want to perform its task first, then >> switch to >> the python console to experiment with further commands, using what was >> already >> defined in the python-program. >> I want this as an alternative for what I do now (but which is not very >> efficient): >> I start the python-console and then manually copy-paste line per line from >> the program in the console, then try out possible continuation commands, >> if however something goes wrong I have to redo the whole process. > > On the command line, python itself can take command line options, > including one that does exactly what you're looking for. > > python -i script.py > > That command will run script.py to its end, then drop you into the > interactive interpreter with the environment intact from running the > script. This is effectively what Idle does when you run code in an editor window. You can interactive with the result in the Shell window. If there is a traceback, right click on a line in the traceback and select 'goto' to go the the spot of the foul. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2013-12-19 08:24 +0100 |
| Message-ID | <l8u6vv$iuj$1@dont-email.me> |
| In reply to | #62337 |
Am 18.12.13 21:17, schrieb Jean Dubois:
> I have a python-program which I want to perform its task first, then
> switch to
> the python console to experiment with further commands, using what was
> already
> defined in the python-program.
Excellent way to use/debug a scripting langugage. Use ipython, and then
either
%run myfile.py
or
execfile('myfile.py')
You can do this multiple times, where the new definitions overwrite the
old ones. In any case, ipython is much more friendly to use at the
command prompt than plain python.
Christian
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-19 07:33 +0000 |
| Message-ID | <mailman.4402.1387438431.18130.python-list@python.org> |
| In reply to | #62381 |
On 19/12/2013 07:24, Christian Gollwitzer wrote:
> Am 18.12.13 21:17, schrieb Jean Dubois:
>> I have a python-program which I want to perform its task first, then
>> switch to
>> the python console to experiment with further commands, using what was
>> already
>> defined in the python-program.
>
> Excellent way to use/debug a scripting langugage. Use ipython, and then
> either
>
> %run myfile.py
>
> or
>
> execfile('myfile.py')
>
> You can do this multiple times, where the new definitions overwrite the
> old ones. In any case, ipython is much more friendly to use at the
> command prompt than plain python.
>
> Christian
>
execfile is Python 2 only.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web