Re: weekdays in range

2009-10-19 Thread Jive Dadson
I'm using weekdays as a proxy for days when the US stock market is open. (I'll miss holidays.) The application is pricing CALL and PUT options. Speed is not a problem. The number of days will typically be between 1 and 254. -- http://mail.python.org/mailman/listinfo/python-list

weekdays in range

2009-10-19 Thread Jive Dadson
(Sorry if this shows up twice.) Can someone think of an easy way to calculate the number of weekdays between two calendar dates (in Python)? Thankee. -- http://mail.python.org/mailman/listinfo/python-list

Re: weekdays in range

2009-10-18 Thread Dave Angel
Jive Dadson wrote: Wow. It's a danged tutorial. Thanks again. Take a break. Ben Finney's method is a very good approach, and an experienced Python programmer would consider it straightforward. But I have to ask whether the range of dates you might be considering could be large. For ex

Re: weekdays in range

2009-10-18 Thread Jive Dadson
Wow. It's a danged tutorial. Thanks again. Take a break. -- http://mail.python.org/mailman/listinfo/python-list

Re: weekdays in range

2009-10-18 Thread Ben Finney
Jive Dadson writes: > Ben Finney wrote: > > >>> friday_weekday = 4 > > >>> len([ > > ... date for date in ( > > ... begin_date + datetime.timedelta(days) > > ... for days in range((end_date - begin_date).days)) > > ... if calendar.weekday(date.year,

Re: weekdays in range

2009-10-18 Thread Jive Dadson
Ben Finney wrote: Jive Dadson writes: Can someone think of an easy way to calculate the number of weekdays between two calendar dates (in Python)? That depends on what you mean by “weekdays”. >>> import datetime >>> begin_date = datetime.date(2009, 10, 9) >>> end_date = datetime

Re: weekdays in range

2009-10-17 Thread Ben Finney
Jive Dadson writes: > Can someone think of an easy way to calculate the number of weekdays > between two calendar dates (in Python)? That depends on what you mean by “weekdays”. >>> import datetime >>> begin_date = datetime.date(2009, 10, 9) >>> end_date = datetime.date(2009, 10, 22