"Steven D'Aprano" <[EMAIL PROTECTED]> writes: > > def _accumulate_properties(self, properties): > > self.properties = [] > > Probably better to put that in the __init__ method, otherwise if > somebody runs instance._accumulate_properties(...) again, it will > have the side-effect of throwing away whatever was already in > instance.properties.
That's the point of naming it with a leading underscore. You've already explained that this is convention for "Private, don't use". > Some people might argue that if someone runs a private method like > _accumulate_properties, they deserve whatever bad things happen to > them. But I say, well, sure, but why *design* your method to break > things when called twice? Exactly the same could be said for calling the __init__ method twice. > Who knows, maybe you'll decide you want to call it twice yourself. Right. In which case, it's good that it's already in a separate, clearly-named, single-purpose method. Make the code easy to understand, not idiot-proof. -- \ "One time a cop pulled me over for running a stop sign. He | `\ said, 'Didn't you see the stop sign?' I said, 'Yeah, but I | _o__) don't believe everything I read.'" -- Steven Wright | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list