Fwd: [Question #189464]: How to run __main__ programs inside python-mode?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Fwd: [Question #189464]: How to run __main__ programs inside python-mode?

Andreas Röhler-2
New question #189464 on python-mode.el:

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 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?

Python-mode mailing list
[hidden email]