A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/311501.html below:

Find day of week from month and year

Find day of week from month and yearCarsten Haese carsten at uniqsys.com
Fri Sep 2 16:56:42 EDT 2005
On Fri, 2005-09-02 at 16:46, Laguna wrote:
> Paul,
> 
> Thanks for the suggestion on calendar module. Here is my solution and
> it works:
> 
> def expiration(year, month):
> 	weekday = calendar.weekday(year, month, 1)
> 	table = [19, 18, 17, 16, 15, 21, 20]
> 	return table[weekday]
> 
> Cheers,
> Laguna

This, of course, can be "optimized" into

def expiration(year, month):
    return [19,18,17,16,15,21,20][calendar.weekday(year,month,1)]

;)

-Carsten



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4