Greetings,<br><br>I have a class that implements the iterator protocol, and tokenises a string into a series of tokens. As well as the token, it keeps track of some information such as line number, source file, etc.<br><br>
for tokens in Tokeniser():<br> do_stuff(token)<br><br>What I want is to be able to wrap the tokeniser to add functionality to the base parser without subclassing, e.g.<br><br>for tokens in processor(Tokeniser()):<br>
do_stuff(token)<br><br>Sort of Decorator pattern, so that I can chain more processors, but I cannot think how to implement it. Any clues for me?<br><br>Thanks<br><br>TomH<br><br><br>
<br>
<div style id="avg_ls_inline_popup"></div>