Hi,
I am a beginner in programming of python , in python to view all the functions and other objects of 'keyword' module,i used the command ,dir results the some objects like __file__,__package__,__doc__ but these are not the functions of keyword module,could u please tell me the reason................. :D

>>> import keyword
>>> dir(keyword)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'i
skeyword', 'kwlist', 'main']

Thanks
Mukthyar azam

Sometimes it is too easy, no dir (kwlist is suprisingly list):

>>> keyword.kwlist
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 
'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in',
'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while',
'with', 'yield']
>>> print('\n'.join(keyword.kwlist))
and
as
assert
break
class
continue
def
del
elif
else
except
exec
finally
for
from
global
if
import
in
is
lambda
not
or
pass
print
raise
return
try
while
with
yield

Interestingly BBCode does not color as and with

Edited 5 Years Ago by pyTony: n/a

This question has already been answered. Start a new discussion instead.