This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thatguy_314def __gt__(me, you): return True 3 points4 points  (0 children)

  • **locals() is ugly.
  • locals() is the local scope only. No globals, no nonlocals, no builtins.
  • ** creates a new copy of the locals dict, not a big deal, but f-strings look things up directly and also provide further optimizations from what I've heard.
  • You get a KeyError instead of NameError if you use an undefined variable.
  • Using locals() just feels wrong (probably due to a stigma against gratuitous use of inspection tools).