Python Identifiers

Python’s identifiers are case-sensitive names for entities in the source code, i.e. for functions, classes and variables.

Some identifiers have a reserved meaning:

Reserved Pattern Example Meaning
_* (leading underscore) _do_something Weak "internal use" indicator, e.g. from M import * does not import objects whose name starts with an underscore.
__ * (double leading underscore) __common_name Any identifier of the form __spam (at least two leading underscores, at most one trailing underscore) is textually replaced with _classname__spam, where classname is the current class name with leading underscore(s) stripped. Used to avoid name conflicts.
* (double leading and trailing underscore) __init__ "magic" objects or attributes that live in user-controlled namespaces. E.g. __init__ , __import__ or __file__ . Never invent such names; only use them as documented.

TODO:

Add some examples of identifiers and the above rules

Add some examples of errors when using keywords.

Show nicely formatted keyword list:

False
None
True
and
as
assert
break
class
continue
def
del
elif
else
except
finally
for
from
global
if
import
in
is
lambda
nonlocal
not
or
pass
raise
return
try
while
with
yield

In [ ]:


In [ ]:


In [ ]:


In [ ]: