[prev in list] [next in list] [prev in thread] [next in thread]
List: python-idle-dev
Subject: Re: [Idle-dev] Setting Command Line Arguments in IDLE
From: Terry Reedy <tjreedy () udel ! edu>
Date: 2019-05-26 16:40:20
Message-ID: 861a65db-cfdd-059b-f70a-9c1e7ccc3405 () udel ! edu
[Download RAW message or body]
On 5/26/2019 7:22 AM, Richard Damon wrote:
> I am working on a python script that will be provided arguments when run
> from the system command line. Is there any place in IDLE to provide
> equivalent arguments for testing while developing in IDLE?
This is the subject of https://bugs.python.org/issue5680. There is a PR
that needs to be reviewed.
> Is there any way to define the working directory for the program when
> run under IDLE,
> or will it always be the directory the script is in (it will be typically
> run using the PATH, so not the same directory as the script)?
os.chdir(path)
> If not, is there an easy way to detect that I am running in IDLE so I
> can fake the command line arguments when testing?
import sys
if __name__ == '__main__':
if 'idlelib.run' in sys.modules:
sys.argv.extend(('a', '-2')) # add your argments here.
print(sys.argv) # in use, parse sys.argv after extending it
['', 'a', '-2'] # in my test in Shell
--
Terry Jan Reedy
_______________________________________________
IDLE-dev mailing list
IDLE-dev@python.org
https://mail.python.org/mailman/listinfo/idle-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic