Search notes:

Python: dir

dir(), without an argument, lists the names in the current local scope.
After starting a python shell, dir() prints
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
Importing a module adds its name the local scope:
>>> import xml
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'xml']
With an argument (which needs to represent an object, dir(obj) reports the object's attributes. In our case, the attributes of xml can now be queried with doc(xml):
>>> dir (xml)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
Importing a «sub-module» (if this is the correct terminology) does not add anything to the current local scope:
>>> import xml.dom.minidom
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'xml']
However, it is listed in the attribute list of xml:
>>> dir(xml)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'dom']
>>> dir (xml.dom)
['DOMException', 'DOMSTRING_SIZE_ERR', 'DomstringSizeErr', 'EMPTY_NAMESPACE', … etc. etc. … ]
A name can be removed from a namespace with the del statement:
>>> del xml
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']

See also

dir() gets the list of names from __dir__ or __dict__
Python: Built in functions
JavaScript: console.dir(obj).

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741107463, '3.131.13.161', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/built-in-functions/dir/index(77): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78