w3resource

Python: globals() function

globals() function

The globals() function returns a dictionary representing the current global symbol table.

Version

(Python 3.2.5)

Syntax:

globals()

Parameters:

No parameters.

Example: Python globals() function

globals()

Output:

{'__cached__': None, '__builtins__': <module 'builtins' (built-in)>, '__package__': None, '__name__': '__main__', '__file__': '/tmp/sessions/33e5bf74fcdfcd2c/main.py', '__spec__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7f465fd5e3c8>, '__doc__': None}

Python Code Editor:

Previous: getattr()
Next: hash()

Test your Python skills with w3resource's quiz



Python: Tips of the Day

How do I check if a list is empty?

For example, if passed the following:

a = []
if not a:
  print("List is empty")

Ref: https://bit.ly/2A4JXx9