I wanted to see if shlex good choice for something that I was trying to build, so I thought it was in debug mode to play with it. Only the shlex constructor has the weird thing it does : it sets self.debug to 0 , and then immediately checks to see if it really is.
… 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 that Python has some powerful metaprogramming functions, but I can't figure out how this works, even if I override the constructor, there is no programmatic way to get between setting the value and using it.
Should there be a way to output the instruction in if self.debug (and if so, how?), Is this an error, or is there some third possibility that I have not considered?
python shlex
kojiro
source share