Naming convention for non-inplace methods (was Re: PRE-PEP: new Path class)

Peter Hansen peter at engcorp.com
Thu Jan 8 16:23:39 CET 2004


Syver Enstad wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> 
> > I haven't been following (either discussion) closely, but this
> > sounds similar to some posts I read about a discussing involved a
> > .reverse() method, and the apparent conclusion that .reversed()
> > [note the 'd'] was more appropriate as it didn't imply that the
> > object was being modified in-place, but that it was returning a
> > reversed version of itself.  Same thing could apply here...
> 
> Good point, but what about asNormalized() or asReversed()? Or
> as_reversed() or as_normalized() if that is the coding
> convention. Doesn't that communicate the intent even better?

I wouldn't object strenuously to any one of the three approaches,
although the simple .normalized() and .reversed() version feels 
slightly more Pythonic to me, merely because the other two don't
seem to be existing conventions in, say, the standard libraries.

I'd go with whatever precedent has already been set, if one has 
been set, and otherwise open a new discussion as the topic has a
lot of merit...

-Peter



More information about the Python-list mailing list