jeudi 30 janvier 2014

Re: Another surprise from the datetime module topic




On 31Jan2014 11:35, Ben Finney <(E-Mail Removed)> wrote:
> Cameron Simpson <(E-Mail Removed)> 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 <(E-Mail Removed)>

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





Aucun commentaire:

Enregistrer un commentaire