[CentralOH] Ugliest Line of Python Ever?

Chris Chandler chris at developingchris.com
Thu Oct 28 03:13:51 CEST 2010

what about?

from datetime import datetime,timedelta,time,date
print datetime.combine(game.gametime.date() - timedelta(days=1), time(12,0))

Then at least its less,hand wavy with the formatting.

Chris Chandler

On Wed, Oct 27, 2010 at 8:20 PM, Jon Miller <jonebird at gmail.com> wrote:

> I think I just typed the ugliest line of python code in iPython
> ever?... and I don't mind sharing it since you might get a chuckle out
> of it:
> In [18]: datetime.datetime(*[ int(x) for x in (game.gametime -
> datetime.timedelta(hours=24)).strftime('%Y %m %d 12 0').split()])
> Out[18]: datetime.datetime(2010, 10, 27, 12, 0)
> I was trying to create a datetime object for twelve noon on the
> previous day before the game.
> (game is the DB object and game.gametime should be pretty obvious)
> I'm going to split it up for readability but I'm still don't have a
> better way to do this.
> -- Jon Miller
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20101027/c452fab3/attachment.html>

More information about the CentralOH mailing list