By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

how can I interpret a file within the interactive interpreter

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.