calling __init__ more than once?
Skip Montanaro
skip at pobox.com
Sun Sep 2 20:32:09 EDT 2001
Roy> I've got a file parsing class which in which I call a single parser
Roy> object repeatedly to parse additional files. Something like:
Roy> p = myParser()
Roy> stuff1 = p.parse (fileName1)
Roy> stuff2 = p.parse (fileName2)
Roy> Is there any reason why my parse method couldn't call __init__() to
Roy> reset things back to the start state? It feels kind of creepy, but
Roy> I don't see any reason why it should be a problem. Is there
Roy> something I'm missing here, or is it really OK to call __init__()
Roy> again?
I suppose you could call __init__ multiple times, but why not define a
clear() or reset() method that __init__ calls to reset state? You could
then call it as well when you wanted to parse a new file.
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list