0

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

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by pyTony
0

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 by pyTony: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.