This text loads when I open IDLE or load Python in cmd:
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.
Where can I find the file and change the text or make a script load instead?
print() is the command you are looking for. The print() function, formally print statement in Python 2.0, can be used to output text from both the python shell and within a python module.
The Python interactive console (also called the Python interpreter or Python shell) provides programmers with a quick way to execute commands and try out or test code without creating a file.
The console appears as a tool window every time you choose the corresponding command on the Tools menu. You can assign a shortcut to open Python console: press Ctrl+Alt+S , navigate to Keymap, specify a shortcut for Main menu | Tools | Python or Debug Console.
I don't know of any way to change the default text without modifying/recompiling the python binary, but it seems you can use the environment variable PYTHONSTARTUP
in order to add additional text via a python file with print
commands. You can also change the prompt strings in this file. For example:
in my .bashrc:
export PYTHONSTARTUP=/home/jake/.mypythonstartup
/home/jake/.mypythonstartup:
import sys
print("Welcome, master!")
sys.ps1 = "How may I serve you? "
sys.ps2 = " ... "
Result:
$ 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?
Documentation on PYTHONSTARTUP
can be found here: https://docs.python.org/3/tutorial/appendix.html#the-interactive-startup-file
Based on a quick snoop around the idlelib
source code, you could do something like:
from code import interact
interact("Welcome master.")
In use:
$ python idle2.py
Welcome master.
>>> print 'foo'
foo
You could also use the command line flags to run a command then enter interactive mode:
$ python -ic "print 'Welcome master.'"
Welcome master.
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With