简体   繁体   中英

How to run a custom script on the launch of IDLE on Mac?

When I click IDLE icon, IDLE shell opens! It looks like this

Python IDLE shell just after startup

So, there is a script that runs whenever I launch IDLE, and this scripts has commands that print

"Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information. ".

1- Is it possible to locate this file on my computer(Mac) and edit it? if yes, how?
2- Is it possible to add another separate script to run at startup? if yes, how?
3- I initially wanted some easy way to clean the shell, the easiest way was to define a function like this
def cls(): print('\n' * 44)
I don't want to write it whenever the shell was restarted. any other solution for this problem will be helpful

Thanks

  1. Currently , the startup script is idlelib/pyshell.py . You can edit it in IDLE (make a backup first), by loading it with File >= Load module and entering idlelib.pyshell in the dialog.

  2. See Command Line Usage in the IDLE doc, available in IDLE as Help >= IDLE Help . In particular, "-s run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window", where XYZSTARTUP is an environmental variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM