Message from discussion DurationField, request for help and comments
Received: by 10.210.39.8 with SMTP id m8mr41665ebm.4.1243367170280;
Tue, 26 May 2009 12:46:10 -0700 (PDT)
Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com [184.108.40.206])
by gmr-mx.google.com with ESMTP id 15si1479388ewy.4.2009.05.26.12.46.09;
Tue, 26 May 2009 12:46:09 -0700 (PDT)
Received-SPF: pass (google.com: domain of gulop...@gmail.com designates 220.127.116.11 as permitted sender) client-ip=18.104.22.168;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gulop...@gmail.com designates 22.214.171.124 as permitted sender) smtp.mail=gulop...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by ewy9 with SMTP id 9so4563416ewy.13
for <firstname.lastname@example.org>; Tue, 26 May 2009 12:46:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
DomainKey-Signature: a=rsa-sha1; c=nofws;
Received: by 10.210.17.2 with SMTP id 2mr665935ebq.19.1243367168282; Tue, 26
May 2009 12:46:08 -0700 (PDT)
From: Marty Alchin <gulop...@gmail.com>
Date: Tue, 26 May 2009 15:45:48 -0400
Subject: Re: DurationField, request for help and comments
Content-Type: text/plain; charset=ISO-8859-1
On Tue, May 26, 2009 at 2:16 PM, Jerome Leclanche <adys...@gmail.com> wrote:
> Right now, removing months and years is a matter of removing two lines
> from the patch. I didn't want to write a patch just to get told "it's
> lacking months/years!"; I'm also in favour of dropping it and
> following Python's style; but up until now no one except yourself and
> Yuri have given feedback, I had no reason to drop it.
My only beef here is that Yuri did mention it, with reasonable
justification in the ticket, and you did acknowledge that it could be
removed, yet it remained. I can understand the tendency to support as
much as possible until someone reigns you in, but once someone does,
it's best to listen. But, I've spoken my peace and it sounds like
we're on the same page now, so we move on.
> As for the current syntax, I believe with a small syntax helper
> somewhere next to the field, this would be and feel completely
> natural. 01:30:10 is a bit meaningless if you're not working in
> seconds. One of my application uses standard milliseconds durations,
> would I have to write 01:30:10.5 to have another 500ms? Would I need
> 1-2 other fields for milli/microseconds - which would make us go back
> to the former problem ("Many input boxes is not a nice user
In my view, yes, 01:30:10.5 (or 01:30:10.500000 if you prefer) would
be the better approach. I will, however, freely admit that my support
for that syntax is based on nothing more than personal preference and
a vague idea of what I believe to be more common. I don't have any
research to back it up, but I don't expect any of us do in this area.
A quick search reveals that ISO 8601 is the relevant specification
here, which would leave us with something along the lines of
PT01H30M10S. In addition to being not-so-user-friendly, it seems ISO
8601 doesn't provide for anything smaller than a second, so we're back
to that same problem anyway.
> That's the way I was going until someone came up with the idea of
> parsing a timestring. Looking back, this is much more elegant, as long
> entirely dropped since it's extremely easy to input any kind of value,
> and the user doesn't have to convert any kind of value. If the user
> wants 17 weeks, they just input "17w" instead of having to calculate
> 119 days. If they want "1500 seconds", same thing; so on.
I'll admit, my preferred approach does drop support for weeks, and if
you were to put in more than 24 hours, 60 minutes or 60 seconds, you'd
get a big, fat error message instead of the implicit calculations that
timedelta does behind the scenes. I still disagree with the notion
that the current syntax is "extremely easy to input any kind of
value," but again, neither statement is based on very much, so it's
likely impossible to say which is "better".
We're basically debating between the two representations allowed by
ISO 8601, at least in spirit. It seems an international panel of
experts couldn't decide on one over the other either, so they allow
both. Unfortunately, that's not really in keeping with Python
philosophy ("There should be one-- and preferably only one --obvious
way to do it."), so we need to pick one or the other. Whichever way we
go, it seems some of us will be Dutch, some of us won't. Such is life.
At this point, I'd say we should table the discussion on input syntax
until after 1.1 is out the door, so we can get some input from people
who have more sway in these matters. And yes, I do realize that I'm
the one who brought it up. ;)
I've seen this argument before, and it doesn't hold water. A
field, it just makes it a bit easier for those who need a little help.
just like the existing date and time fields.
> As for a wrapper TimeDelta class, that's up to Yuri to explain - I
> don't see the problem with it personally.
I wasn't pointing fingers at anybody in particular, I just don't see
that it adds anything beyond Python's own datetime.timedelta. Once
years and months are removed, it basically just performs unit
conversion and provides an output format in line with the new input
syntax. Python's timedelta already does the unit conversion, so that's
just duplicated effort. As for the output format, I'd rather see that
handled at the widget level anyway, so any other Python code that
deals with timedeltas doesn't get a shock when the output isn't what
Python normally provides.