I wanted to see if shlex
was a good choice for something I'm trying to build, so I thought I'd put it in debug mode to play around with it. Only, shlex's constructor has this weird thing it does: it sets self.debug
to 0
and then immediately checks if it's true.
…
self.debug = 0
self.token = ''
self.filestack = deque()
self.source = None
if self.debug:
print 'shlex: reading from %s, line %d' \
% (self.instream, self.lineno)
I know Python has some powerful metaprogramming features, but I can't figure out how this is intended to work – even if I override the constructor, there's no programmatic way to get between the setting of the value and its use.
Is there supposed to be a way to output the statement in the if self.debug
condition (and if so, how?), is it a bug, or is there some third possibility I haven't considered?