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

Reply via email to