Another surprise from the datetime module

Cameron Simpson cs at zip.com.au
Thu Jan 30 21:01:40 EST 2014


On 31Jan2014 11:35, Ben Finney <ben+python at benfinney.id.au> wrote:
> Cameron Simpson <cs at zip.com.au> writes:
> > Hmm. I do not like the replace() as suggested.
> >
> > Firstly, replace is a verb, and I would normally read
> > td.replace(microseconds=0) as an instruction to modify td in place.
> > Traditionally, such methods in python return None.
> 
> I agree with this objection. A method that is named “replace”, yet does
> not modify the object, is badly named.
> 
> However, the existing ‘replace’ methods ‘datetime.date.replace’,
> ‘datetime.datetime.replace’, ‘datetime.time.replace’ already work this
> way: they create a new value and return it, without modifying the
> original object.

Ah.
-- 
Cameron Simpson <cs at zip.com.au>

DRM: the functionality of refusing to function. - Richard Stallman



More information about the Python-list mailing list