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
> 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