how to develop code using a mix of an existing python-program and console-commands

J

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.
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
 
J

Joel Goldstick

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


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
 
J

Jerry Hill

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.
 
J

Joel Goldstick

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.

Wow, Jerry, I didn't know that one. Cool
 
M

Mark Lawrence

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.
 
T

Terry Reedy

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.
 
J

Jean Dubois

Op woensdag 18 december 2013 21:28:05 UTC+1 schreef Jerry Hill:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,743
Latest member
WoodrowMea

Latest Threads

Top