What object is being queried when I call dir() in Python’s interpreter?
I’m playing with a package that I want to be able to get the names for functions from the global dictionary. I thought that it would be dir(__global) but that wasn’t it, nor was dir(sys.modules).
If I type dir() into a fresh interpreter session it says
['__builtins__', '__doc__', '__name__', '__package__']
What would be the ob in dir(ob) that would give me this same response?
dir()returns names in the current scope. I can’t remember now if it’s exactly equivalent tolocals().keys(), or are there any differences.