Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ?

Reply
Thread Tools

datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ?

 
 
Christos TZOTZIOY Georgiou
Guest
Posts: n/a
 
      09-08-2003
Is there any reason for datetime.time subtraction not returning a
datetime.timedelta object, just like datetime.datetime subtraction does?
It doesn't feel good having to use dumb year, month, day arguments
constructing datetime object when doing only time arithmetic.

If there is no specific reason apart from lack of time (no pun), I'm
willing to research it and write a patch (I haven't seen the code, but I
believe it would be quite easy).

TIA
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
 
Reply With Quote
 
 
 
 
Christos TZOTZIOY Georgiou
Guest
Posts: n/a
 
      09-09-2003
On Mon, 8 Sep 2003 20:57:46 -0400, rumours say that "Tim Peters"
<> might have written:

>[Christos TZOTZIOY Georgiou]
>> Is there any reason for datetime.time subtraction not returning a
>> datetime.timedelta object, just like datetime.datetime subtraction
>> does?

>
>Guido didn't want time objects participating in arithmetic because the
>desired semantics are unclear. For example, if you allow
>
> time1 - time2
>
>to return a timedelta, then you'll also want to allow
>
> time2 + timedelta
>
>to return a time, and then you've got to make up rules for what happens when
>adding spills over a midnight boundary. Should it "wrap around"? Raise
>OverflowError? Guido didn't want to endure arguments about that.


So it's by design.

[snip of the above not applying to datetime objects]

>> It doesn't feel good having to use dumb year, month, day
>> arguments constructing datetime object when doing only time
>> arithmetic.

>
>What's wrong with using timedeltas?
>
>>>> print timedelta(hours=3, minutes=15) - timedelta(hours=2, minutes=45)

>0:30:00


A perfectly clear solution; it's just the RTFM-F [1] virus, I overlooked
the keyword arguments...

>> If there is no specific reason apart from lack of time (no pun), I'm
>> willing to research it and write a patch (I haven't seen the code,
>> but I believe it would be quite easy).

>
>Selling it would be harder than writing it.


Basically, I asked for some reasoning --which you provided in the first
paragraphs of your reply-- just in case the issue was overlooked; since
it wasn't (and I got a solution!), I'm OK and not at all anxious to sell
a patch

Thanks.

[1] final F standing for First
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
 
Reply With Quote
 
 
 
 
Tim Roberts
Guest
Posts: n/a
 
      09-11-2003
Christos "TZOTZIOY" Georgiou <> wrote:
>--
>TZOTZIOY, I speak England very best,
>Microsoft Security Alert: the Matrix began as open source.


Can you please end my suspense and explain what TZOTZIOY means? Some how,
"Time Zone Out, Time Zone In, One Year" just doesn't cut it.
--
- Tim Roberts,
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
Christos TZOTZIOY Georgiou
Guest
Posts: n/a
 
      09-13-2003
On Wed, 10 Sep 2003 21:35:30 -0700, rumours say that Tim Roberts
<> might have written:

>>TZOTZIOY, I speak England very best,

>
>Can you please end my suspense and explain what TZOTZIOY means? Some how,
>"Time Zone Out, Time Zone In, One Year" just doesn't cut it.


Suspense? Wow!

Well, it's not an English acronym, it's just a unique word, a play on my
last name which facilitates identifying my posts (ie Google searches,
and DejaNews in older times). Just that.

Earlier replies to similar questions:
http://groups.google.com/groups?selm...rt37%404ax.com
http://groups.google.com/groups?selm...47.102.222.230

PS The Guide is useful too: http://www.bbc.co.uk/dna/h2g2/U83754
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57