[CentralOH] Ugliest Line of Python Ever?
chris at developingchris.com
Thu Oct 28 03:13:51 CEST 2010
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.
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 : datetime.datetime(*[ int(x) for x in (game.gametime -
> datetime.timedelta(hours=24)).strftime('%Y %m %d 12 0').split()])
> Out: 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the CentralOH