Python Forum
why globals() exits python when quit() is aliased as q
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why globals() exits python when quit() is aliased as q
#3
You remapped quit.__repr__() to call quit(). Then you assign a variable (q) to reference quit. When you type globals() it prints q: q.__repr__(), but __repr__() now does quit() instead of returning a string. Boom! I mean, that is why typing "q" works, why wouldn't you expect the same thing for globals().
Reply


Messages In This Thread
RE: why globals() exits python when quit() is aliased as q - by deanhystad - May-23-2023, 02:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to avoid exec(), globals(), locals(), eval() paul18fr 10 5,430 Apr-21-2021, 05:53 PM
Last Post: snippsat
  accessing globals from a function Skaperen 8 4,389 Sep-01-2018, 11:50 PM
Last Post: Skaperen
  snake game quit() ^ SyntaxError: invalid syntax arti 1 4,151 Jan-17-2018, 06:26 PM
Last Post: buran
  Use of Globals CWatters 5 3,991 Nov-13-2017, 09:00 PM
Last Post: CWatters
  Globals vs Function mcmxl22 2 3,472 Feb-04-2017, 11:38 AM
Last Post: ichabod801
  Check if an duplicate exits in a list Server94 9 7,323 Jan-31-2017, 04:56 PM
Last Post: Server94

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020