python-interpreter

How to clear python interpreter console?

Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wonde...

How can you programmatically tell the CPython interpreter to enter interactive mode when done?

If you invoke the cpython interpreter with the -i option, it will enter the interactive mode upon completing any commands or scripts it has been given to run. Is there a way, within a program to get the interpreter to do this even when it has not been given -i? The obvious use case is in debugging by interactively inspecting the state w...

How to re import an updated package while in Python Interpreter ?

I often test my module in the Python Interpreter, and when I see an error, I quickly update the .py file. But how do I make it reflect on the Interpreter ? So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me. ...

What is the purpose of the sub-interpreter API in CPython?

I'm unclear on why the sub-interpreter API exists and why it's used in modules such as the mod_wsgi apache module. Is it mainly used for creating a security sandbox for different applications running within the same process, or is it a way to allow concurrency with multiple threads? Maybe both? Are there other purposes? ...

Persistant Python Command-Line History

Hello, I'd like to be able to "up-arrow" to commands that I input in a previous Python interpreter. I have found the readline module which offers functions like: read_history_file, write_history_file, and set_startup_hook. I'm not quite savvy enough to put this into practice though, so could someone please help? My thoughts on the so...

Nice copying from Python Interpreter

Hi all, When I am working with a Python Interpreter, I always find it a pain to try and copy code from it because it inserts all of these >>> and ... Is there a Python interpreter that will let me copy code, without having to deal with this? Or alternatively, is there a way to clean the output. Additionally, sometimes I would like to ...

drop into python interpreter while executing function

i have a python module with a function: def do_stuff(param1 = 'a'): if type(param1) == int: # enter python interpreter here do_something() else: do_something_else() is there a way to drop into the command line interpreter where i have the comment? so that if i run the following in python: >>> import m...

How to resolve bindings during execution with embedded Python?

I'm embedding Python into a C++ application. I plan to use PyEval_EvalCode to execute Python code, but instead of providing the locals and globals as dictionaries, I'm looking for a way to have my program resolve symbol references dynamically. For example, let's say my Python code consists of the following expression: bear + lion * ...

How to run python top level/interpreter with file input?

I've always wondered how to do this, it's useful for manual unit testing of individual python scrips. Say I had a python file that did something, and I wanted to run it in the top level, but after it finishes, I want to pick up where it leaves off. I want to be able to use the objects it creates, etc. A simple example, let's say I have...

Is there a way to view the source code of a function, class, or module from the python interpreter?

Is there a way to view the source code of a function, class, or module from the python interpreter? (in addition to using help to view the docs and dir to view the attributes/methods) ...

Eclipse using multiple Python interpreters with execnet

Hi there, I'm using the execnet package to allow communication between Python scripts interpreted by different Python interpreters. The following code (test_execnet.py): import execnet for python_version in ('python', 'python3'): try: gw = execnet.makegateway("popen//python="+python_version) ch = gw....

Python Compilation/Interpretation Process

Hey all, I'm trying to understand the python compiler/interpreter process more clearly. Unfortunately, I have not taken a class in interpreters nor have I read much about them. Basically, what I understand right now is that Python code from .py files is first compiled into python bytecode (which i assume are the .pyc files i see occasio...

Linux kernel that runs python file for init

Would it be possible and not incredibly difficult to build a linux kernel, with a python interpreter built in or accessible from the kernel, that could run a python file as it's init process? ...

messed up pythonpath when using multiple interpreters

Hi there, I have a third party program that I use for remotely calling my own application and uses python 2.4. My Application is written with python 2.6. So this is the call hierarchy: 3rd party app -> calling my app by Python24 -> my app Now when calling my application via "C:\Python26\python.exe " contains a python26.zip file and all...