> I'm working on an article about Python introspection and came across > something I consider a blemish. I thought I'd ask about it here and > see how you folks 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 > attribute: > > >>> import keyword > >>> dir(keyword) > ['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'iskeyword', > 'keyword', 'kwdict', 'kwlist', 'main'] > >>> keyword.keyword > 'yield' > >>> > > Basically, the keyword attribute is just the last value from this > process: > > kwdict = {} > for keyword in kwlist: > kwdict[keyword] = 1 > > So it is a bit of extraneous cruft, I believe. No big deal, and > nothing that a > > del keyword > > couldn't fix. But it does look sloppy when you are writing about > introspection and you see an attribute that has no real value. I > wish it weren't there, as I'd rather not have to explain it. But it > got me thinking whether other modules in the standard library have > this issue, and whether this is something that should be cleaned > up. Thoughts? Lots of modules have attributes that are cruft according to this definition. I personally see no reason to get rid of all these -- they're harmless and "from M import *" doesn't import them. Feel free to hold your own code to a higher standard though. ;-) --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4