473,657 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing interactive interpreter without (-i)

Hello All,

If there a way a script can tell Python to enter interactive mode even if
the -i command line switch was not given?

I want py2exe to create an interactive session, without writing my own
REPL.

Thanks.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zo ran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
Jul 18 '05 #1
2 1840
Miki Tebeka <mi*********@zo ran.com> writes:
Hello All,

If there a way a script can tell Python to enter interactive mode even if
the -i command line switch was not given?

I want py2exe to create an interactive session, without writing my own
REPL.


IIRC, in newer Python versions, you can set the PYTHONINSPECT env var inside
your script.

Thomas
Jul 18 '05 #2
In Movable Python I use IPython and code.Interactiv eConsole to provide
interactive sessions.

See the file 'movpy.py' in the source distribution to see the code.
Note that to get IPython working with py2exe you must effectively do an
explicit `import site`.
def interactive(loc alvars=None):
"""A very simple function to embed an interactive interpreter into movpy."""
# could have the banner passed in as an optional argument, plus
maybe the IPython config file location IPShellEmbed = None
try:
from IPython.Shell import IPShellEmbed
except ImportError:
pass if not IPShellEmbed or IPOFF:
if localvars == None:
localvars = sys._getframe(0 ).f_back.f_loca ls # extract locals from the calling frame - taken from IPython from code import InteractiveCons ole
con = InteractiveCons ole(localvars)
con.interact()
else:
banner = 'Movable Python\nIPython Interactive Shell. See the manual for a list of features and tips.\nCtrl-D to exit.' argv = ['-ipythondir', libdir] # where to find the ipython config file ipshell = IPShellEmbed(ar gv, banner=banner)
ipshell()


http://sourceforge.net/projects/movpy
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #3

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

Similar topics

2
3500
by: Dave Reed | last post by:
I seem to remeber reading somewhere there was a statement you could put in your python program to stop its execution and start the interactive interpreter at that point (and then you could change the value of some variables and continue executing). Am I having delusions or is there a way to do this? Thanks, Dave
0
1009
by: Jonas Galvez | last post by:
Hi, I just upgraded to Python 2.3.3, and I'm getting this: http://www.jonasgalvez.com/unsorted/weirdo.png Win2k, brazilian portuguese, latest Apache and mod_python. I believe it must a line ending parsing problem... It's really strange, 2.3.2 used to run smoothly. Also, I'm able to run the interactive interpreter from inside IDLE. Can anyone help me? =-
0
1201
by: Jonas Galvez | last post by:
A few days ago I posted about a problem I was having on Win2k, regarding a SyntaxError error on the interactive interpreter to anything I typed. The thread is located here: tinyurl.com/2kk7b I've mode some progress on this. I noticed that the problem in fact lies on the line break. If I place a # on the end of the line, Python has no problem interpreting it: C:\>python Python 2.3.3 (#51, Dec 18 2003, 20:22:39) on win32
5
1713
by: linuxnow | last post by:
I don't know what I'm doing wrong, but the result is that _import_ only works from a python shell, but not when I call a python script. $ cat test.py mod = __import__("/home/me/tests/test_imp") Called from a script it does not work: $ python /home/me/test.py Traceback (most recent call last): File "/home/pau/test.py", line 1, in ?
0
1204
by: Simon Eves | last post by:
I am trying to write a Python module to embed the functionality of Maya (the 3D modelling and animation application from Autodesk, formerly Alias) for doing scripted scene manipulation and rendering processes in Python. I am aware of the CGKit project, which does this and a lot more, but it is over-complex for our needs, and also does not work in the context of a pure command-line Python script, only as an alternative scripting language...
0
834
by: Ryan K | last post by:
Hi. I am trying to embed an interactive interpreter in a C++ application. I need to capture the output of int PyRun_InteractiveOne(FILE *fp, const char *filename). Is redirecting sys.stdout and sys.stderr after initializing the interpreter the best way to do this? Thanks, Ryan
4
3303
by: yan.python | last post by:
i have a question. when i run Interactive Interpreter in linux command promt,how can i move the cursor. for example,when i enter a string,i often enter the quotation mark "" first,and the move the cursor inside the mark to enter the string,in windows,it is ok.but when i do that in linux,pressing the "left" key will just print "^[[D" in the screen ,but not what i want. so , how can i move the cursor Interactive Interpreter in linux? i've...
3
1879
by: R. Bernstein | last post by:
The next release of pydb will have the ability to go into ipython from inside the debugger. Sort of like how in ruby-debug you can go into irb :-) For ipython, this can be done pretty simply; there is an IPShellEmbed method which returns something you can call. But how could one do the same for the stock python interactive shell? To take this out of the realm of debugging. What you want to do is to write a python program that goes...
2
984
by: The Pythonista | last post by:
I remember the interactive interpreter used to define the name _ to return the value of the last expression that was evaluated. However, I tried it just today and got a NameError. Is this a change in the interpreter or is there a configuration option I need to set to enable it? Thanks! -- code.py: A blog about life, the universe, and Python
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.