472,779 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

how can I interpret a file within the interactive interpreter

I want to interpret a file (or whatever you call it) and then keep the
interactive interpreter alive so I can then continue to issue commands.

How can this be done? I saw online a -m flag but it does not seem to work.

Thanks
--
Peter Bismuti
Boeing
Nov 13 '07 #1
4 1277
Peter J. Bismuti wrote:
I want to interpret a file (or whatever you call it) and then keep the
interactive interpreter alive so I can then continue to issue commands.

How can this be done? I saw online a -m flag but it does not seem to
work.
Use the -i-flag.

Diez
Nov 13 '07 #2
Peter J. Bismuti wrote:
I want to interpret a file (or whatever you call it) and then keep the
interactive interpreter alive so I can then continue to issue commands.
That's what the -i option is for.
How can this be done? I saw online a -m flag but it does not seem to work.
-m is used to load a module via python's import mechanism.

$ echo 'print "Hello from", __name__' tmp.py

$ python -m tmp
Hello from __main__

$ python -i tmp.py
Hello from __main__
>>>
You can combine both options:

$ python -i -m tmp
Hello from __main__
>>>
Peter
Nov 13 '07 #3
Still can't get the -m flat to work. Perhaps this feature is not in the
version I am using? Thanks.
-bash-3.00$ python -m test
Unknown option: -m
usage: python [option] ... [-c cmd | file | -] [arg] ...
Try `python -h' for more information.
-bash-3.00$ python
Python 2.3.4 (#1, Jan 9 2007, 16:40:09)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>



Peter J. Bismuti wrote:
I want to interpret a file (or whatever you call it) and then keep the
interactive interpreter alive so I can then continue to issue commands.

That's what the -i option is for.
How can this be done? I saw online a -m flag but it does not seem to
work.

-m is used to load a module via python's import mechanism.

$ echo 'print "Hello from", __name__' tmp.py

$ python -m tmp
Hello from __main__

$ python -i tmp.py
Hello from __main__
You can combine both options:

$ python -i -m tmp
Hello from __main__
Peter
--
Peter Bismuti
Boeing Information Technology
Renton, WA
(425) 234-0873 W
(425) 442-7775 C
Nov 13 '07 #4
Peter J. Bismuti wrote:
Still can't get the -m flat to work. Perhaps this feature is not in the
version I am using? Thanks.
-m isn't the option you want. -i it is. And yes, -m appeared in later python
versions - I'm not exactly sure which one grew it, might be 2.3 or even
2.4. But -i is older.

Diez
Nov 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: leroybt.rm | last post by:
I don't understand why this does not work: <FILE1> test1.py #Import Packages import string # data=0 data=data+1
147
by: Sateesh | last post by:
Hi, I am a beginner in Python, and am wondering what is it about the indentation in Python, without which python scripts do not work properly. Why can't the indentation not so strict so as to give...
22
by: Sunner Sun | last post by:
Hi, all Since the OS look both ASCII and binary file as a sequence of bytes, is there any way to determine the file type except to judge the extension? Thank you!
6
by: nibiery | last post by:
I am just getting started with Python, and I think I may be thinking about it wrong. I'd like to be able to work interactively with some code that I've got in a file. The only interpreted language...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.