Io non conosco alcun modo per cambiamento il testo predefinito senza modificare/ricompilare il binario pitone, ma sembra che è possibile utilizzare la variabile di ambiente PYTHONSTARTUP
al fine di aggiungere ulteriore testo tramite un file di pitone con print
comandi . È inoltre possibile modificare le stringhe di prompt in questo file. Per esempio:
nel mio .bashrc:
export PYTHONSTARTUP=/home/jake/.mypythonstartup
/home/jake/.mypythonstartup:
import sys
print("Welcome, master!")
sys.ps1 = "How may I serve you? "
sys.ps2 = " ... "
Risultato:
$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Welcome, master!
How may I serve you? def test():
... print("test")
...
How may I serve you? test()
test
How may I serve you?
documentazione sul PYTHONSTARTUP
può essere trovato qui : https://docs.python.org/3/tutorial/appendix.html#the-interactive-startup-file
fonte
2015-04-29 21:00:31
hahaha, È divertente, ma perché vuoi farlo ? – ZdaR
Haha felice che ti piaccia ... Ho solo pensato che sarebbe stato bello essere accolti da qualcosa come "Benvenuto maestro". – Coco
Puoi vedere il codice sorgente 'idlelib': https://hg.python.org/cpython/file/293d9964cf6e/Lib/idlelib – jonrsharpe