Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-22 Thread Jess Austin
On Thu, Apr 16, 2009 at 8:01 PM, Jess Austin wrote: > These operations are useful in particular contexts.  What I've > submitted is also useful, and currently isn't easy in core, > batteries-included python.  While I would consider the foregoing > interpretation of the Zen to be backwards (this do

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-18 Thread Lennart Regebro
On Thu, Apr 16, 2009 at 08:18, Jess Austin wrote: > hi, > > I'm new to python core development, and I've been advised to write to > python-dev concerning a feature/patch I've placed at > http://bugs.python.org/issue5434, with Rietveld at > http://codereview.appspot.com/25079. > > This patch adds a

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread Aahz
On Fri, Apr 17, 2009, BJ?rn Lindqvist wrote: > > It's not only about what people find intuitive. Why care about them? > Most persons aren't programmers. It is about what application > developers find useful too. I have often needed to calculate month > deltas according to the proposal. I suspect ma

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread BJörn Lindqvist
It's not only about what people find intuitive. Why care about them? Most persons aren't programmers. It is about what application developers find useful too. I have often needed to calculate month deltas according to the proposal. I suspect many other programmers have too. Writing a month add func

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread skip
>> "2rd of March on leap years, > ^^^ > The turd of March? Yeah, it's from a little known Shakespearean play about a benevolent dictator, Guidius van Rossumus. The name of the play escapes me at the moment, but there's this critical scene where the BDFL is in mortal danger because

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread Antoine Pitrou
James Y Knight fuhm.net> writes: > > It's a human-interface operation, and as such, everyone (ahem) "knows > what it means" to say "2 months from now", but the details don't > usually have to be thought about too much. I don't think it's true. When you say "2 months from now", some people wi

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread Antoine Pitrou
Jess Austin gmail.com> writes: > > I have worked in utility/telecom billing, and needed to examine large > numbers of invoice dates, fulfillment dates, disconnection dates, > payment dates, collection event dates, etc. There would often be > particular rules for the relationships among these dat

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread Jeroen Ruigrok van der Werven
-On [20090417 04:55], s...@pobox.com (s...@pobox.com) wrote: >Again, I think it needs to bake a bit. I understand the desire and need for >doing date arithmetic with months. Python is mature enough though that I >don't think you can just "toss this in". It should be available as a module >outsid

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-17 Thread Robert Kern
On 2009-04-16 21:55, s...@pobox.com wrote: Jess> If, on the other hand, one of the committers wants to toss this in Jess> at some point, whether now or 3 versions down the road, the patch Jess> is up at bugs.python.org (and I'm happy to make any suggested Jess> modificatio

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Greg Ewing
Steven D'Aprano wrote: "2rd of March on leap years, ^^^ The turd of March? -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-de

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread skip
Jess> If, on the other hand, one of the committers wants to toss this in Jess> at some point, whether now or 3 versions down the road, the patch Jess> is up at bugs.python.org (and I'm happy to make any suggested Jess> modifications). Again, I think it needs to bake a bit. I unde

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Steven D'Aprano
On Fri, 17 Apr 2009 07:47:14 am Antoine Pitrou wrote: > Jess Austin gmail.com> writes: > > What other behavior options besides "last-valid-day-of-the-month" > > would you like to see? > > IMHO, the question is rather what the use case is for the behaviour > you are proposing. In which kind of situ

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread glyph
On 16 Apr, 11:11 pm, f...@fuhm.net wrote: On Apr 16, 2009, at 5:47 PM, Antoine Pitrou wrote: It's a human-interface operation, and as such, everyone (ahem) "knows what it means" to say "2 months from now", but the details don't usually have to be thought about too much. Of course when you ha

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Steven D'Aprano
On Fri, 17 Apr 2009 12:29:11 pm Steven D'Aprano wrote: > Adding one month to 31st January could mean: > > 1: raise an exception > 2: return 28th February (last day of February) > 3: return 3rd April (1 month = 31 days) > 4: return 2nd April (1 month = 30 days) > 5: return 28th February (1 month =

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Steven D'Aprano
On Fri, 17 Apr 2009 07:41:19 am Jess Austin wrote: > Others have suggested raising an exception when a month calculation > lands on an invalid date. Python already has that; it's spelled like > > this: > >>> dt = date(2008, 1, 31) > >>> dt.replace(month=dt.month + 1) > > Traceback (most recent ca

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
On Thu, Apr 16, 2009 at 7:18 PM, wrote: > >    >> I have this funny feeling that arithmetic using monthdelta wouldn't >    >> always be intuitive. > >    Jess> I think that's true, especially since these calculations are not >    Jess> necessarily invertible: > >    >>> date(2008, 1, 30) + monthd

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Tennessee Leeuwenburg
My thoughts on balance regarding monthdeltas: -- Month operations are useful, people will want to do them -- I think having a monthdelta object rather than a method makes sense to me -- I think the documentation is severely underdone. The functionality is not intuitive and therefore the

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread skip
>> I have this funny feeling that arithmetic using monthdelta wouldn't >> always be intuitive. Jess> I think that's true, especially since these calculations are not Jess> necessarily invertible: >>> date(2008, 1, 30) + monthdelta(1) datetime.date(2008, 2, 29) >>> dat

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread James Y Knight
On Apr 16, 2009, at 5:47 PM, Antoine Pitrou wrote: IMHO, the question is rather what the use case is for the behaviour you are proposing. In which kind of situation is it acceptable to turn 31/2 silently into 29/2? Essentially any situation in which you'd actually want a "next month" oper

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
Antoine Pitrou wrote: > Jess Austin gmail.com> writes: >> >> What other behavior options besides "last-valid-day-of-the-month" >> would you like to see? > > IMHO, the question is rather what the use case is for the behaviour you are > proposing. In which kind of situation is it acceptable to turn

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Robert Kern
On 2009-04-16 17:17, Paul Moore wrote: 2009/4/16 Robert Kern: from dateutil.relativedelta import * dt = relativedelta(months=1) dt relativedelta(months=+1) from datetime import datetime datetime(2009, 1, 15) + dt datetime.datetime(2009, 2, 15, 0, 0) datetime(2009, 1, 31) + dt datetime.dat

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Paul Moore
2009/4/16 Robert Kern : > On 2009-04-16 13:42, Paul Moore wrote: >> >> 2009/4/16 Ned Deily: >>> >>> In article >>> , >>>  Jess Austin  wrote: I'm new to python core development, and I've been advised to write to python-dev concerning a feature/patch I've placed at http://bugs.py

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Eric Smith
Jess Austin wrote: What other behavior options besides "last-valid-day-of-the-month" would you like to see? - Add 30 days to the source date. I'm sure there are others. Followups to python-ideas. ___ Python-Dev mailing list Python-Dev@python.org htt

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Antoine Pitrou
Jess Austin gmail.com> writes: > > What other behavior options besides "last-valid-day-of-the-month" > would you like to see? IMHO, the question is rather what the use case is for the behaviour you are proposing. In which kind of situation is it acceptable to turn 31/2 silently into 29/2? ___

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
Jon Ribbens wrote: > On Thu, Apr 16, 2009 at 12:10:36PM +0400, Oleg Broytmann wrote: >> > This patch adds a "monthdelta" class and a "monthmod" function to the >> > datetime module.  The monthdelta class is much like the existing >> > timedelta class, except that it represents months offset from a

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Robert Kern
On 2009-04-16 13:42, Paul Moore wrote: 2009/4/16 Ned Deily: In article , Jess Austin wrote: I'm new to python core development, and I've been advised to write to python-dev concerning a feature/patch I've placed at http://bugs.python.org/issue5434, with Rietveld at http://codereview.appspot.

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jared Grubb
On 16 Apr 2009, at 11:42, Paul Moore wrote: The key thing missing (I believe) from dateutil is any equivalent of monthmod. I agree with that. It's well-defined and it makes a lot of sense. +1 But, I dont think monthdelta can be made to work... what should the following be? print(date(200

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
Thanks for everyone's comments! On Thu, Apr 16, 2009 at 9:54 AM, Paul Moore wrote: > I like the idea in principle. In practice, of course, month > calculations are inherently ill-defined, so you need to be very > specific in documenting all of the edge cases, and you should have > strong use case

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
On Thu, Apr 16, 2009 at 5:16 AM, Dirkjan Ochtman wrote: > On Thu, Apr 16, 2009 at 11:54, Amaury Forgeot d'Arc > wrote: >> In my opinion: >> arithmetic with months is a mess. There is no such "month interval" or >> "year interval" with a precise definition. >> If we adopt some kind of month manip

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
On Thu, Apr 16, 2009 at 4:54 AM, Amaury Forgeot d'Arc wrote: > FWIW, the Oracle database has two methods for adding months: > 1- the add_months() function >    add_months(to_date('31-jan-2005'), 1) > 2- the ANSI interval: >    to_date('31-jan-2005') + interval '1' month > > "add_months" is calenda

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Paul Moore
2009/4/16 Ned Deily : > In article > , >  Jess Austin wrote: >> I'm new to python core development, and I've been advised to write to >> python-dev concerning a feature/patch I've placed at >> http://bugs.python.org/issue5434, with Rietveld at >> http://codereview.appspot.com/25079. > > Without ha

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Paul Moore
2009/4/16 Antoine Pitrou : > Paul Moore gmail.com> writes: >> >> Oh, certainly! But in the absence of "intuitive", I've found in the >> past that "standardised" is often better than nothing  (For >> example, I use Oracle's add_months function fairly often - it's not >> perfect, and not always intu

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jess Austin
On Thu, Apr 16, 2009 at 3:45 AM, wrote: >    >>> date(2008, 1, 30) + monthdelta(1) >    datetime.date(2008, 2, 29) > > What would this loop would print? > >    for d in range(1, 32): >        print date(2008, 1, d) + monthdelta(1) >>> for d in range(1, 32): ... print(date(2008, 1, d) + mont

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Ned Deily
In article , Jess Austin wrote: > I'm new to python core development, and I've been advised to write to > python-dev concerning a feature/patch I've placed at > http://bugs.python.org/issue5434, with Rietveld at > http://codereview.appspot.com/25079. Without having looked at the code, I wonder

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Antoine Pitrou
Paul Moore gmail.com> writes: > > Oh, certainly! But in the absence of "intuitive", I've found in the > past that "standardised" is often better than nothing (For > example, I use Oracle's add_months function fairly often - it's not > perfect, and not always intuitive, but at least it's well-def

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Paul Moore
2009/4/16 : >    >>> date(2008, 1, 30) + monthdelta(1) >    datetime.date(2008, 2, 29) > > What would this loop would print? > >    for d in range(1, 32): >        print date(2008, 1, d) + monthdelta(1) > > I have this funny feeling that arithmetic using monthdelta wouldn't always > be intuitive.

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Paul Moore
2009/4/16 Jess Austin : > I'm new to python core development, and I've been advised to write to > python-dev concerning a feature/patch I've placed at > http://bugs.python.org/issue5434, with Rietveld at > http://codereview.appspot.com/25079. > > This patch adds a "monthdelta" class and a "monthmod

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Jon Ribbens
On Thu, Apr 16, 2009 at 12:10:36PM +0400, Oleg Broytmann wrote: > > This patch adds a "monthdelta" class and a "monthmod" function to the > > datetime module. The monthdelta class is much like the existing > > timedelta class, except that it represents months offset from a date, > > rather than an

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Dirkjan Ochtman
On Thu, Apr 16, 2009 at 11:54, Amaury Forgeot d'Arc wrote: > In my opinion: > arithmetic with months is a mess. There is no such "month interval" or > "year interval" with a precise definition. > If we adopt some kind of month manipulation, it should be a function > or a method, like you would do

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Amaury Forgeot d'Arc
On Thu, Apr 16, 2009 at 10:45, wrote: >    >>> date(2008, 1, 30) + monthdelta(1) >    datetime.date(2008, 2, 29) > > What would this loop would print? > >    for d in range(1, 32): >        print date(2008, 1, d) + monthdelta(1) > > I have this funny feeling that arithmetic using monthdelta would

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread James Pye
On Apr 16, 2009, at 1:10 AM, Oleg Broytmann wrote: This patch adds a "monthdelta" class and a "monthmod" function to the datetime module. The monthdelta class is much like the existing timedelta class, except that it represents months offset from a date, rather than an exact period offset from a

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread skip
>>> date(2008, 1, 30) + monthdelta(1) datetime.date(2008, 2, 29) What would this loop would print? for d in range(1, 32): print date(2008, 1, d) + monthdelta(1) I have this funny feeling that arithmetic using monthdelta wouldn't always be intuitive. Skip

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Oleg Broytmann
On Thu, Apr 16, 2009 at 01:18:01AM -0500, Jess Austin wrote: > I'm new to python core development, and I've been advised to write to > python-dev concerning a feature/patch I've placed at > http://bugs.python.org/issue5434, with Rietveld at > http://codereview.appspot.com/25079. I have read the

Re: [Python-Dev] Issue5434: datetime.monthdelta

2009-04-16 Thread Tennessee Leeuwenburg
Hi Jess, I'm sorry if I'm failing to understand the use of this function from not looking closely at your code. I'm a bit dubious about the usefulness of this (I'm not sure I understand the use cases), but I'm very open to being convinced. Datetime semantics are very important in some areas -- I u