Passing command line argument to program from within IDLE?

Steve Holden steve at holdenweb.com
Thu Feb 4 22:28:17 CET 2010


Terry Reedy wrote:
> On 2/4/2010 3:55 PM, Alan Biddle wrote:
>> Just finishing my first Python (2.6 on Win XP)  program, which is
>> working fine.  My "Duh?" question is about how to run it from within
>> IDLE and pass it command line arguments.  No problem using sys.argv
>> from a Windows command line, but I have missed how you can do that
>> from within IDLE, which complicates development and debugging.
> 
> I presume you mean edit, F5-run, see result in shell window.
> Set sys.argv in test function or __name__=='__main__'
> In 3.1 idle shell:
> 
>>>> import sys
>>>> sys.argv
> ['']
>>>> sys.argv = ['abc','dev']
>>>> sys.argv
> ['abc', 'dev']
> 
> I did not know it was writable, either, until I tried it.
> 
As a solution, however, that sucks, wouldn't you agree?

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list