Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > > > Cameron Simpson 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

Re: Another surprise from the datetime module

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > 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. That's how str.r

Re: Another surprise from the datetime module

2014-01-30 Thread Roy Smith
In article <52eb1e37$0$29972$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > "replace" is a perfectly reasonable name for a method which performs a > replacement, whether it replaces in place (for mutable objects) or makes > a copy with replacement (for immutable objects). What e

Re: Another surprise from the datetime module

2014-01-30 Thread Steven D'Aprano
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > Cameron Simpson 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

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 31Jan2014 11:35, Ben Finney wrote: > Cameron Simpson 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

Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Cameron Simpson 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

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 30Jan2014 18:36, Neil Cerutti wrote: > On 2014-01-30, Roy Smith wrote: > > I was astounded just now to discover that datetime.timedelta > > doesn't have a replace() method (at least not in Python 2.7). > > Is there some fundamental reason why it shouldn't, or is this > > just an oversight? > >

Re: Another surprise from the datetime module

2014-01-30 Thread Neil Cerutti
On 2014-01-30, Roy Smith wrote: > I was astounded just now to discover that datetime.timedelta > doesn't have a replace() method (at least not in Python 2.7). > Is there some fundamental reason why it shouldn't, or is this > just an oversight? > > My immediate use case was wanting to print a timed

Re: Another surprise from the datetime module

2014-01-30 Thread Mark Lawrence
On 30/01/2014 17:32, Roy Smith wrote: I was astounded just now to discover that datetime.timedelta doesn't have a replace() method (at least not in Python 2.7). Is there some fundamental reason why it shouldn't, or is this just an oversight? My immediate use case was wanting to print a timedelt