Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65087

Re: Another surprise from the datetime module

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Another surprise from the datetime module
Date 2014-01-31 15:40 +1100
References <lce63h$c88$1@ger.gmane.org> <20140131000631.GA69776@cskk.homeip.net> <mailman.6184.1391128528.18130.python-list@python.org> <52eb1e37$0$29972$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.6189.1391143222.18130.python-list@python.org> (permalink)

Show all headers | View raw


Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:

> On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote:
>
> > Cameron Simpson <cs@zip.com.au> writes:
> >> 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.
>
> […] What else would you call it?

I'd call it “substitute”, and keep thinking until I came up with
something better.

I wouldn't think very hard, though, because the existing usage of
‘foo.replace’ for a create-new-object-with-different-values method is
fairly well established in the Python built-in types and standard
library. Local expectations do, past some threshold, override general
expectations for the meaning of a term.

-- 
 \       “Everyone is entitled to their own opinions, but they are not |
  `\            entitled to their own facts.” —US Senator Pat Moynihan |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Another surprise from the datetime module Ben Finney <ben+python@benfinney.id.au> - 2014-01-31 11:35 +1100
  Re: Another surprise from the datetime module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-31 03:53 +0000
    Re: Another surprise from the datetime module Roy Smith <roy@panix.com> - 2014-01-30 22:58 -0500
    Re: Another surprise from the datetime module Ben Finney <ben+python@benfinney.id.au> - 2014-01-31 15:40 +1100
  Re: Another surprise from the datetime module Dan Sommers <dan@tombstonezero.net> - 2014-01-31 04:04 +0000

csiph-web