Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Chris Angelico
On Sat, Mar 29, 2014 at 12:10 AM, Marko Rauhamaa wrote: > If encapsulation exists outside OO and inheritance is not key to it, > what is OO then, a marketing term? > Yep, OO is a marketing term. So's programming - after all, it's just flipping bits in memory... we only pretend it means anything.

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Marko Rauhamaa
Roy Smith : > I'm not sure how "decoupling internal representation from external > behavior" is substantially different from encapsulation. Yes, that's encapsulation. The idea of encapsulation is older than OO. > And, no, I don't think inheritance is a fundamental characteristic of > OOD, nudge

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Steven D'Aprano
On Fri, 28 Mar 2014 08:30:11 -0400, Roy Smith wrote: > In article <533558fa$0$29994$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> > Yes. The whole idea of OOD is to decouple internal representation >> > from external behavior. >> >> The *whole* idea? You don't think that

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Marko Rauhamaa
Roy Smith : > There're certainly not mutually exclusive. Mutually exclusive means if > you have one, you can't have the other. Correct. The classic inheritance diamond: class A(B, C): def add_bean(self): ??? # how to implement class B(D): pass class C(D): pass cl

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Chris Angelico
On Sat, Mar 29, 2014 at 1:35 AM, Steven D'Aprano wrote: > It's difficult to pin-point exactly what characteristics of OOP are > fundamental, but inheritance is surely one of them. I've always understood OOP to be all about binding code and data together (methods as part of an object, rather than

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Rustom Mody
On Friday, March 28, 2014 6:52:15 PM UTC+5:30, Roy Smith wrote: > Chris Angelico wrote: > > On Sat, Mar 29, 2014 at 12:10 AM, Marko Rauhamaa wrote: > > > If encapsulation exists outside OO and inheritance is not key to it, > > > what is OO then, a marketing term? > > Yep, OO is a marketing term.

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Roy Smith
In article <871txmwjt4@elektro.pacujo.net>, Marko Rauhamaa wrote: > what is OO then, a marketing term? Sometimes, I think it must be :-) > (It's a different thing, then, that encapsulation and inheritance are > mutually exclusive principles.) There're certainly not mutually exclusive. Mu

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Chris Angelico
On Sat, Mar 29, 2014 at 12:22 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Sat, Mar 29, 2014 at 12:10 AM, Marko Rauhamaa wrote: >> > If encapsulation exists outside OO and inheritance is not key to it, >> > what is OO then, a marketing term? >> > >> >> Yep, OO is a market

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Roy Smith
In article , Chris Angelico wrote: > On Sat, Mar 29, 2014 at 12:10 AM, Marko Rauhamaa wrote: > > If encapsulation exists outside OO and inheritance is not key to it, > > what is OO then, a marketing term? > > > > Yep, OO is a marketing term. So's programming - after all, it's just > flipping b

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Roy Smith
In article <533558fa$0$29994$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > Yes. The whole idea of OOD is to decouple internal representation from > > external behavior. > > The *whole* idea? You don't think that encapsulation and inheritance > might also be involved? *wink*

Re: YADTR (Yet Another DateTime Rant)

2014-03-28 Thread Steven D'Aprano
On Thu, 27 Mar 2014 20:29:17 -0400, Roy Smith wrote: > In article <5334b747$0$29994$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> On Thu, 27 Mar 2014 08:52:24 -0400, Roy Smith wrote: >> >> > In article , >> > Chris Angelico wrote: >> >> It's not "equally braindead", it f

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Fri, Mar 28, 2014 at 1:24 PM, Terry Reedy wrote: > I do know that the people responsible are not normally braindead ;-). Yeah, anyone who develops Python is clearly abnormally braindead... *dives for cover* ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Terry Reedy
On 3/27/2014 9:59 PM, Roy Smith wrote: In article , Terry Reedy wrote: On 3/27/2014 5:10 PM, Terry Reedy wrote: On 3/27/2014 7:42 AM, Chris Angelico wrote: In any case... what I'd suggest would be opening a tracker issue, or discussing this on python-ideas, and seeing what core devs think

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Roy Smith
In article , Terry Reedy wrote: > On 3/27/2014 5:10 PM, Terry Reedy wrote: > > On 3/27/2014 7:42 AM, Chris Angelico wrote: > > > >> In any case... what I'd suggest would be opening a tracker issue, or > >> discussing this on python-ideas, and seeing what core devs think of > >> the matter. I thi

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Terry Reedy
On 3/27/2014 5:10 PM, Terry Reedy wrote: On 3/27/2014 7:42 AM, Chris Angelico wrote: In any case... what I'd suggest would be opening a tracker issue, or discussing this on python-ideas, and seeing what core devs think of the matter. I think that, on balance, it's probably better to show the wh

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Ben Finney
Roy Smith writes: > In article <5334b747$0$29994$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > > > On Thu, 27 Mar 2014 08:52:24 -0400, Roy Smith wrote: > > > Give ma a real-life situation where you would want such behavior > > > [the ‘datetime.timedelta.__str__’ method returni

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Roy Smith
In article <5334b747$0$29994$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 27 Mar 2014 08:52:24 -0400, Roy Smith wrote: > > > In article , > > Chris Angelico wrote: > >> It's not "equally braindead", it follows a simple and logical rule: > >> Only the day portion is ne

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Ethan Furman
On 03/27/2014 02:10 PM, Terry Reedy wrote: On 3/27/2014 7:42 AM, Chris Angelico wrote: In any case... what I'd suggest would be opening a tracker issue, or discussing this on python-ideas, and seeing what core devs think of the matter. I think that, on balance, it's probably better to show the

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Steven D'Aprano
On Thu, 27 Mar 2014 08:52:24 -0400, Roy Smith wrote: > In article , > Chris Angelico wrote: >> It's not "equally braindead", it follows a simple and logical rule: >> Only the day portion is negative. > > Simple and logical, yes. But also entirely braindead. Do you think it is "braindead" for

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Terry Reedy
On 3/27/2014 7:42 AM, Chris Angelico wrote: In any case... what I'd suggest would be opening a tracker issue, or discussing this on python-ideas, and seeing what core devs think of the matter. I think that, on balance, it's probably better to show the whole thing with the same sign; but should i

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Antoon Pardon
On 27-03-14 13:52, Roy Smith wrote: >> On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer wrote: >>> Besides, there's an infinite amount of (braindead) timedelta string >>> representations. For your -30 hours, it is perfectly legal to say >>> >>> 123 days, -2982 hours >>> >>> Yet Python doesn't (but

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Marko Rauhamaa
Skip Montanaro : > Feel free to submit a patch to improve str(t), where t is negative, The cat's out of the bag already, isn't it? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Fri, Mar 28, 2014 at 1:12 AM, Antoon Pardon wrote: > I don't recall specifics, but I do remember multiple times > where I was working with a structure that consisted of > a whole part and a fracture part where I found it useful > to have the fracture part always positive and displayed > as such

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Skip Montanaro
>> There are, >> as I see it, two common cases where t is negative: >> >> -1 day < t < 0 >> >> and >> >> t <= -1 day > > There are two types of negative numbers: Those closer to zero than -1, > and those not closer to zero than -1. Yeah, I think those are the most > common cases. :) Sorry I wa

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Roy Smith
> On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer wrote: > > Besides, there's an infinite amount of (braindead) timedelta string > > representations. For your -30 hours, it is perfectly legal to say > > > > 123 days, -2982 hours > > > > Yet Python doesn't (but chooses an equally braindead represen

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Thu, Mar 27, 2014 at 10:56 PM, Skip Montanaro wrote: > There are, > as I see it, two common cases where t is negative: > > -1 day < t < 0 > > and > > t <= -1 day There are two types of negative numbers: Those closer to zero than -1, and those not closer to zero than -1. Yeah, I think those

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Skip Montanaro
I took a moment to scan the datetime documentation. The behavior of str() on timedelta objects is very consistent, and matches the internal representation. From the docs: str(t) Returns a string in the form [D day[s], ][H]H:MM:SS[.UU], where D is negative for negative t. (5) Note (5) reads: S

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Thu, Mar 27, 2014 at 10:25 PM, Johannes Bauer wrote: > And it makes it extremely error-prone to the reader: > str(datetime.timedelta(0, -1)) > '-1 day, 23:59:59' > > This looks MUCH more like "almost two days ago" than > > '-00:00:01' > > does. It's easy when the timedelta is >-1 day. Is

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Thu, Mar 27, 2014 at 10:05 PM, Johannes Bauer wrote: > On 27.03.2014 11:44, Chris Angelico wrote: >> On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer wrote: >>> Besides, there's an infinite amount of (braindead) timedelta string >>> representations. For your -30 hours, it is perfectly legal to

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 11:44, Chris Angelico wrote: > It's not "equally braindead", it follows a simple and logical rule: > Only the day portion is negative. The more I think about it, the sillier this rule seems to me. A timedelta is a *whole* object. Either the whole delta is negative or it is not. It

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 11:44, Chris Angelico wrote: > On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer wrote: >> Besides, there's an infinite amount of (braindead) timedelta string >> representations. For your -30 hours, it is perfectly legal to say >> >> 123 days, -2982 hours >> >> Yet Python doesn't (but

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Chris Angelico
On Thu, Mar 27, 2014 at 9:22 PM, Johannes Bauer wrote: > Besides, there's an infinite amount of (braindead) timedelta string > representations. For your -30 hours, it is perfectly legal to say > > 123 days, -2982 hours > > Yet Python doesn't (but chooses an equally braindead representation). It's

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 27.03.2014 01:16, Steven D'Aprano wrote: > py> divmod(30, 24) > (1, 6) > > That makes perfect intuitive sense: 30 hours is 1 day with 6 hours > remaining. In human-speak, we'll say that regardless of whether the > timedelta is positive or negative: we'll say "1 day and 6 hours from now" > o

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Johannes Bauer
On 26.03.2014 10:53, Jean-Michel Pichavant wrote: > Note : I don't see what's wrong in your example, however I have the feeling > the term "stupiditie" is a little bit strong ;) The problem is that for a given timedelta t with t > 0 it is intuitive to think that its string representation str(t)

Re: YADTR (Yet Another DateTime Rant)

2014-03-27 Thread Mark Lawrence
On 27/03/2014 01:38, Roy Smith wrote: In article , Chris Angelico wrote: On Thu, Mar 27, 2014 at 11:16 AM, Steven D'Aprano wrote: If an event happened 30 hours ago, it is correct to say that it occurred "18 hours after 2 days ago", but who talks that way? That response demonstrates real

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Dan Sommers
On Thu, 27 Mar 2014 00:16:57 +, Steven D'Aprano wrote: > py> divmod(-30, 24) > (-2, 18) > > If an event happened 30 hours ago, it is correct to say that it > occurred "18 hours after 2 days ago", but who talks that way? Well, not *exactly*, but: If today happens to be Wednesday, and an even

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Mar 27, 2014 at 11:16 AM, Steven D'Aprano > wrote: > > If an event happened 30 hours ago, it is correct to say that it occurred > > "18 hours after 2 days ago", but who talks that way? > > That response demonstrates real genius. Rue the datetime? Wh

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Chris Angelico
On Thu, Mar 27, 2014 at 11:16 AM, Steven D'Aprano wrote: > If an event happened 30 hours ago, it is correct to say that it occurred > "18 hours after 2 days ago", but who talks that way? That response demonstrates real genius. Rue the datetime? Who talks like that? ChrisA -- https://mail.python

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Steven D'Aprano
On Wed, 26 Mar 2014 19:25:45 -0400, Dennis Lee Bieber wrote: > On Tue, 25 Mar 2014 20:58:27 -0400, Roy Smith declaimed > the following: > >>One of my roles on this newsgroup is to periodically whine about >>stupidities in the Python datetime module. This is one of those times. >> >>I have some

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Ethan Furman
On 03/26/2014 04:25 PM, Dennis Lee Bieber wrote: On Tue, 25 Mar 2014 20:58:27 -0400, Roy Smith declaimed the following: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Gregory Ewing
Chris Angelico wrote: By showing those last ones as 1̅.091... and 2̅.091..., you emphasize the floating-point nature of the data: everything after the decimal is the mantissa, and everything before the decimal is the exponent. The reason for writing them that way is so that you can look the las

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Jean-Michel Pichavant
- Original Message - > One of my roles on this newsgroup is to periodically whine about > stupidities in the Python datetime module. This is one of those > times. > > I have some code which computes how long ago the sun set. Being a > nice > pythonista, I'm using a timedelta to represent

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Ben Finney
Grant Edwards writes: > We're still just papering-over the basic problem: the entire > time/calendar system use by "western civilization" is a mess. I don't > know a lot about other systems in use, but from what I have seen they > were all pretty much just as bad. We should fix the basic problem

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Grant Edwards
On 2014-03-26, Skip Montanaro wrote: > On Wed, Mar 26, 2014 at 10:58 AM, Marko Rauhamaa wrote: >> Fractions of seconds are supported -- the other fields can't be >> fractional. > > Actually, it appears that whatever the last value you give can be > fractionated. From the Wikipedia page you refer

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Marko Rauhamaa
Skip Montanaro : > There is a good reason that the internal units of timedelta objects > are days, seconds, and microseconds. They are well-defined outside of > a calendar context. > > So, I guess Roy is back to square one. He can always roll his own > timedelta subclass and give it a __str__ impl

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Skip Montanaro
On Wed, Mar 26, 2014 at 10:58 AM, Marko Rauhamaa wrote: > Fractions of seconds are supported -- the other fields can't be > fractional. Actually, it appears that whatever the last value you give can be fractionated. From the Wikipedia page you referenced: "The smallest value used may also have

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Marko Rauhamaa
Skip Montanaro : > Note though, that the ISO8601 representation isn't without its own > flaws (which might explain why Tim avoided it BITD): > > * It doesn't appear to provide a way to represent fractions of a > second (though perhaps all the fields can be fractional) > * How many days are in a mo

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Roy Smith
On Mar 26, 2014, at 11:39 AM, Skip Montanaro wrote: > The point of my post was that there is no obvious one best way to > present negative timedeltas in a human readable form. I agree that there are a number of possible representations which might make sense. But, using negative days and positi

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Skip Montanaro
On Wed, Mar 26, 2014 at 10:04 AM, Roy Smith wrote: > No, what you said was "negative four days, positive 3605 seconds". My apologies for not showing all my work, professor. I use datetime and timedelta objects all the time. I did the arithmetic to go from 3605 to one hour, five minutes in my head

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Roy Smith
On Wednesday, March 26, 2014 9:37:06 AM UTC-4, Skip Montanaro wrote: > The problem gets more challenging once you get into magnitudes > one > day: > > >>> e = datetime.timedelta(days=-4, seconds=3605) > >>> e > datetime.timedelta(-4, 3605) > >>> print e > -4 days, 1:00:05 > > Hmmm... It's printi

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Marko Rauhamaa
Antoon Pardon : > On 26-03-14 01:58, Roy Smith wrote: >> previous sunset: -1 day, 22:25:26.295993 >> >> The idea of str() is that it's supposed to return a human-friendly >> representation of a value. Humans do not say things like, "The sun set >> 1 day ago plus 22 hours and 25 minutes". > Ther

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Chris Angelico
On Thu, Mar 27, 2014 at 1:02 AM, Antoon Pardon wrote: > There is a difference between how people say things and what is useful. > I remember when I was studying logarithms, a negative number like -5.73 > was written down as ̅6.27 (with a bar only over the six). That notation > had the advantage th

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Antoon Pardon
On 26-03-14 01:58, Roy Smith wrote: > One of my roles on this newsgroup is to periodically whine about > stupidities in the Python datetime module. This is one of those times. > > I have some code which computes how long ago the sun set. Being a nice > pythonista, I'm using a timedelta to repre

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Skip Montanaro
It's not clear to me what the correct str should be. I think the desired format changes depending on the relative magnitude of the timedelta object. For small values (less than a day), I agree, the behavior is, well, odd. You can get around that easily enough: >>> d = datetime.timedelta(seconds=-

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Mark Lawrence
On 26/03/2014 01:19, Ethan Furman wrote: On 03/25/2014 05:58 PM, Roy Smith wrote: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pyth

Re: YADTR (Yet Another DateTime Rant)

2014-03-25 Thread Ethan Furman
On 03/25/2014 05:58 PM, Roy Smith wrote: One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent

YADTR (Yet Another DateTime Rant)

2014-03-25 Thread Roy Smith
One of my roles on this newsgroup is to periodically whine about stupidities in the Python datetime module. This is one of those times. I have some code which computes how long ago the sun set. Being a nice pythonista, I'm using a timedelta to represent this value. It would be difficult to i