Re: [Tutor] Help with range of months spanning across years

2011-02-02 Thread Steven D'Aprano
ian douglas wrote: It bugs me that so many people are quick to jump on the we wont' do your homework bandwagon -- I was accused of the same thing when I posted a question to the list myself. I've been programming professionally for many years but learning Python in my spare time... I sent

[Tutor] Help with range of months spanning across years

2011-02-01 Thread Sean Carolan
I have a function that accepts four arguments, namely startmonth, startyear, endmonth, and endyear. For example: startmonth = 8 startyear = 2009 endmonth = 1 endyear = 2010 What would be the most straightforward way to create a list of year/month pairs from start to end? I want to end up with

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Hugo Arts
On Wed, Feb 2, 2011 at 12:19 AM, Sean Carolan scaro...@gmail.com wrote: I have a function that accepts four arguments, namely startmonth, startyear, endmonth, and endyear.  For example: startmonth = 8 startyear = 2009 endmonth = 1 endyear = 2010 What would be the most straightforward way

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Alan Gauld
Hugo Arts hugo.yo...@gmail.com wrote What would be the most straightforward way to create a list of year/month pairs from start to end? I want to end up with a list of tuples like this: mylist = [(2009, 8), (2009, 9), (2009, 10), (2009, 11), (2009, 12), (2010, 1)] That said, you can do

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Elwin Estle
--- On Tue, 2/1/11, Sean Carolan scaro...@gmail.com wrote: From: Sean Carolan scaro...@gmail.com Subject: [Tutor] Help with range of months spanning across years To: Tutor@python.org Date: Tuesday, February 1, 2011, 6:19 PM I have a function that accepts four arguments, namely startmonth

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread ian douglas
It bugs me that so many people are quick to jump on the we wont' do your homework bandwagon -- I was accused of the same thing when I posted a question to the list myself. I've been programming professionally for many years but learning Python in my spare time... I sent this reply to Sean

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Sean Carolan
This sounds somewhat like homework. If it is, that's fine, mention it, and we will help you. But we won't do your homework for you, so keep that in mind. A reasonable assumption but this is actually going in a cgi tool that I'm using at work. The input comes from pull-down menus on a web

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Hugo Arts
On Wed, Feb 2, 2011 at 2:30 AM, ian douglas ian.doug...@iandouglas.com wrote: It bugs me that so many people are quick to jump on the we wont' do your homework bandwagon -- I was accused of the same thing when I posted a question to the list myself. I've been programming professionally for many

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Hugo Arts
On Wed, Feb 2, 2011 at 2:55 AM, Sean Carolan scaro...@gmail.com wrote: This sounds somewhat like homework. If it is, that's fine, mention it, and we will help you. But we won't do your homework for you, so keep that in mind. A reasonable assumption but this is actually going in a cgi tool

Re: [Tutor] Help with range of months spanning across years

2011-02-01 Thread Sean Carolan
As far as I can tell from quickly going through documentation, no. At least, not with a quick and easy function. datetime can represent the dates just fine, and you can add days to that until you hit your end date, but adding months is harder. timedelta can't represent a month, which makes