0.1. Help Ⓗ - JulTob/Python GitHub Wiki
🧭 When learning Python, two built-in tools matter a lot: dir() helps you discover what exists, and help() explains how to use it.
The dir function
📋 dir() returns a list of names that exist in some scope: functions, classes, variables, and other objects you can access.
📦 If you pass a module as an argument, dir(Module_Name) returns the names available inside that module.
👀 If you call dir() with no arguments, it lists what’s available in your current environment (the names you can use right now).
import sys
dir(sys) # names available inside the sys module
['__breakpointhook__',
'__displayhook__',
'__doc__',
'__excepthook__',
'__interactivehook__',
'__loader__',
...
'stderr',
'stdin',
'stdlib_module_names',
'stdout',
'thread_info',
'unraisablehook',
'version',
'version_info',
'warnoptions']
dir() # names available in the current environment
['In',
'Out',
...
'exit',
'get_ipython',
'quit',
'sys']
The help function
📖 help() shows documentation for an object: what it does, how to call it, and what arguments it expects.
🔎 If you already know the function you want, you can ask Python directly for instructions like this:
help(max)
⚡ In IPython environments (like Jupyter), there’s a faster shortcut that shows the same idea in a more interactive way:
?max