
"Robin" == Robin Becker <robin@jessikat.fsnet.co.uk> writes:
Robin> from httplib import * Robin> class Bongo(HTTPConnection): Robin> pass ... Robin> NameError: name 'HTTPConnection' is not defined It was a brain fart on my part when creating httplib.__all__. HTTPConnection was not included in that list. I will check in a fix. In the 2.1 release __all__ was defined as __all__ = ["HTTP"] I have changed that to __all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection", "HTTPException", "NotConnected", "UnknownProtocol", "UnknownTransferEncoding", "IllegalKeywordArgument", "UnimplementedFileMode", "IncompleteRead", "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader", "ResponseNotReady", "BadStatusLine", "error"] and will check the change into CVS shortly. (Thomas, keep an eye open for this as an addition to 2.1.1.) The workaround I would choose is to not use from "httplib import *": import httplib class Bongo(httplib.HTTPConnection): pass Robin> Changing the * to HTTPConnection in ttt.py removes the problem. Yup, that will also work. Before anyone asks, "Who died and make Skip King?", the scenario as I recall it was that the semantics of __all__ got settled on during discussions on python-dev (the goal of __all__ being to minimize namespace pollution by "from ... *"), but nobody stepped up immediately to do the gtunt work, so I volunteered. The problem in relying on one person (well, at least this one person) to do this was that I had only the following tools at my disposal to decide what belonged in __all__: * what was documented in the lib reference manual (which was at times incomplete) * my experience with the various modules (some of which was specialized, some of which was nonexistent) * the standard library (which generally doesn't use "from ... *" much) * input from python-dev (whose members also appear not to use "from ... *" very liberally) In retrospect, I probably should have polled c.l.py with a summary of what I came up with before the 2.1 ship date. If people would like me to do that now (before 2.2 gets anywhere close to release) to try and fill in as many missing symbols as possible, let me know. -- Skip Montanaro (skip@pobox.com) (847)971-7098

In message <15126.34635.67975.31473@beluga.mojam.com>, Skip Montanaro <skip@pobox.com> writes
thanks; I'm still a bit puzzled as to the exact semantics. It just looks wrong. Is __all__ the only way to get things into the * version of import? Presumably HTTPConnection is being marked as a potential global in the compile phase. -- Robin Becker

Robin> thanks; I'm still a bit puzzled as to the exact semantics. It Robin> just looks wrong. Is __all__ the only way to get things into the Robin> * version of import? Essentially, yes. If you want to just dispense with it __all__together (=:-o), you can textually replace __all__ with ___all__ in each of the standard library modules: cd /usr/local/lib/python2.1 for f in *.py ; do sed -e 's/___*all__/___all__/g' < $f > $f.tmp mv $f.tmp $f done Note that I didn't touch any files in directories under the basic Lib directory. Robin> Presumably HTTPConnection is being marked as a potential global Robin> in the compile phase. It has nothing to do with module compilation. The contents of __all__ are a static thing in the text of the .py file, and thusfar almost entirely due to me studying the inputs at hand and making a decision about what belonged and what didn't. Some python-dev people caught ommissions and added them before the 2.1 release. Other than that, the mistakes are all mine. I had some misgivings about the whole thing during the midst of the task and still do, but grumbled once and completed it. Skip

In message <15126.34635.67975.31473@beluga.mojam.com>, Skip Montanaro <skip@pobox.com> writes
thanks; I'm still a bit puzzled as to the exact semantics. It just looks wrong. Is __all__ the only way to get things into the * version of import? Presumably HTTPConnection is being marked as a potential global in the compile phase. -- Robin Becker

Robin> thanks; I'm still a bit puzzled as to the exact semantics. It Robin> just looks wrong. Is __all__ the only way to get things into the Robin> * version of import? Essentially, yes. If you want to just dispense with it __all__together (=:-o), you can textually replace __all__ with ___all__ in each of the standard library modules: cd /usr/local/lib/python2.1 for f in *.py ; do sed -e 's/___*all__/___all__/g' < $f > $f.tmp mv $f.tmp $f done Note that I didn't touch any files in directories under the basic Lib directory. Robin> Presumably HTTPConnection is being marked as a potential global Robin> in the compile phase. It has nothing to do with module compilation. The contents of __all__ are a static thing in the text of the .py file, and thusfar almost entirely due to me studying the inputs at hand and making a decision about what belonged and what didn't. Some python-dev people caught ommissions and added them before the 2.1 release. Other than that, the mistakes are all mine. I had some misgivings about the whole thing during the midst of the task and still do, but grumbled once and completed it. Skip
participants (2)
-
Robin Becker
-
Skip Montanaro