ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
[Tutor] Readable date arithmetic
by Stephen Nelson-Smith other posts by this author
Nov 18 2009 10:17PM messages near this date
Re: [Tutor] Why are these results different? | Re: [Tutor] Readable date arithmetic
I have the following method:

def get_log_dates(the_date_we_want_data_for):
  t = time.strptime(the_date_we_want_data_for, '%Y%m%d')
  t2 = datetime.datetime(*t[:-2])
  extra_day = datetime.timedelta(days=1)
  t3 = t2 + extra_day
  next_log_date = t3.strftime('%Y%m%d')
  return (the_date_we_want_data_for, next_log_date)

Quite apart from not much liking the t[123] variables, does date
arithmetic really need to be this gnarly?

How could I improve the above, especially from a readability
perspective?  Or is it ok?

S.
_______________________________________________
Tutor maillist  -  Tutor@[...].org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Thread:
Stephen Nelson-Smith
Bob Gailer
Kent Johnson
Dave Angel

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved