[Twisted-Python] Using usage.Options documentation error
Patrick K. O'Brien
pobrien at orbtech.com
Tue May 27 08:19:37 MDT 2003
There appears to be an error in the code example on this page:
http://www.twistedmatrix.com/documents/howto/options
<quote>
Inheritance, Or: How I Learned to Stop Worrying and Love the Superclass
Sometimes there is a need for several option processors with a
unifying core. Perhaps you want all your commands to understand
-q/--quiet means to be quiet, or something similar. On the face of it,
this looks impossible: in Python, the subclass's optFlags would shadow
the superclass's. However, usage.Options uses special reflection code
to get all of the optFlags defined in the hierarchy. So the following:
class BaseOptions(usage.Options):
optFlags = [["quiet", "q"], None]
class SpecificOptions(BaseOptions):
optFlags = [
["fast", "f", None], ["good", "g", None], ["cheap", "c", None]
]
Is the same as:
class SpecificOptions(BaseOptions):
optFlags = [
["quiet", "q", "Silence output"],
["fast", "f", "Run quickly"],
["good", "g", "Don't validate input"],
["cheap", "c", "Use cheap resources"]
]
</quote>
I don't see how the descriptions in the second SpecificOptions class
match with the use of None in the first set of classes. Twisted is
good, but it isn't *that* good, is it?
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
More information about the Twisted-Python
mailing list