How to run __main__ programs inside python-mode?

Asked by Richard Stanton on 2012-03-02

I'm probably missing something obvious, but what's the best way to use python-mode to run/debug python scripts that are designed to be run from the command line? In particular, the problem I face is that while __main__ is set fine, if my code tries to access sys.argv, it gets information that is not very useful, e.g.,

In [5]: sys.argv
Out[5]: ['/Library/Frameworks/EPD64.framework/Versions/7.2/bin/ipython', '-i']

I could always write a main() function, set up my own argument list, and then call main(myargs), or something similar, but this isn't so convenient when all I want to do is run someone else's sample code.

How do others deal with this? Is there a facility in python-mode (or should there be) to pass a user-defined sys.argv to scripts run by pressing C-c C-c?

Question information

English Edit question
python-mode.el Edit question
No assignee Edit question
Last query:
Last reply:

This question was reopened

Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.