[Python-Dev] Keyword module cruft question
Patrick K. O'Brien
pobrien@orbtech.com
Tue, 29 Oct 2002 16:21:58 -0600
I'm working on an article about Python introspection and came across some=
thing=20
I consider a blemish. I thought I'd ask about it here and see how you fol=
ks=20
feel about it. BTW, I'm looking at Python 2.2.2 on Linux.
If you look at the keyword module, you'll see that it has a keyword attri=
bute:
>>> import keyword
>>> dir(keyword)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'iskeyword=
',=20
'keyword', 'kwdict', 'kwlist', 'main']
>>> keyword.keyword
'yield'
>>>=20
Basically, the keyword attribute is just the last value from this process=
:
kwdict =3D {}
for keyword in kwlist:
kwdict[keyword] =3D 1
So it is a bit of extraneous cruft, I believe. No big deal, and nothing t=
hat a
del keyword
couldn't fix. But it does look sloppy when you are writing about introspe=
ction=20
and you see an attribute that has no real value. I wish it weren't there,=
as=20
I'd rather not have to explain it. But it got me thinking whether other=20
modules in the standard library have this issue, and whether this is=20
something that should be cleaned up. Thoughts?
--=20
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------