May-23-2023, 01:56 AM
I was trying to set up my python so that typing 'q' or 'quit' (instead of 'quit()') will exit the python interpreter, by doing:
type(quit).__repr__ = type(quit).__call__ q=quitBut then I noticed that if I do 'globals()', it will exit the python. Can anybody tell me why this happens? Thanks!
abc12@kc-lenovo@~ 26 $ python Python 3.9.10 (main, Jan 20 2022, 22:28:26) [GCC 11.2.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. Could not open PYTHONSTARTUP FileNotFoundError: [Errno 2] No such file or directory: '/home/mobaxterm/kdrive/misc/dot.pythonrc.py' >>> globals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>} >>> type(quit).__repr__ = type(quit).__call__ >>> q=quit >>> globals() abc12@kc-lenovo@~ 27 $