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


Groups > comp.lang.python > #65075

Re: Another surprise from the datetime module

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'modify': 0.07; 'modifying': 0.07; 'badly': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'way:': 0.09; 'python': 0.11; "(i'm": 0.16; 'behaviour.': 0.16; 'finney': 0.16; 'hmm.': 0.16; 'none.': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simpson': 0.16; 'url:time': 0.16; 'normally': 0.19; 'header:User- Agent:1': 0.23; 'certainly': 0.24; 'replace': 0.24; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'instruction': 0.29; 'object.': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'implemented': 0.33; 'subject:the': 0.34; 'subject:from': 0.34; 'agree': 0.35; 'object,': 0.36; 'received:com.au': 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'tell': 0.60; 'new': 0.61; 'url:3': 0.61; 'such': 0.63; 'skip:\xe2 10': 0.65; '8bit%:21': 0.69; '8bit%:43': 0.74; '8bit%:46': 0.78; 'received:125': 0.84; 'verb,': 0.84; 'skip:\xe2 30': 0.91; 'convinced': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Another surprise from the datetime module
Date Fri, 31 Jan 2014 11:35:14 +1100
References <lce63h$c88$1@ger.gmane.org> <20140131000631.GA69776@cskk.homeip.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host vmx15867.hosting24.com.au
X-Public-Key-ID 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:Xp4pzz0yOxGyr4GZkET83NO/kb4=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6184.1391128528.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391128528 news.xs4all.nl 2912 [2001:888:2000:d::a6]:38556
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65075

Show key headers only | View raw


Cameron Simpson <cs@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.

    <URL:http://docs.python.org/3/library/datetime.html#datetime.date.replace>
    <URL:http://docs.python.org/3/library/datetime.html#datetime.datetime.replace>
    <URL:http://docs.python.org/3/library/datetime.html#datetime.time.replace>

So, if ‘datetime.timedelta.replace’ were to be implemented (I'm not
convinced it is needed), it should have that same behaviour.

-- 
 \      “I tell you the truth: this generation will certainly not pass |
  `\           away until all these things [the end of the world] have |
_o__)   happened.” —Jesus Christ, c. 30 CE, as quoted in Matthew 24:34 |
Ben Finney

Back to comp.lang.python | Previous | NextNext 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