[CentralOH] Ugliest Line of Python Ever?
jonebird at gmail.com
Thu Oct 28 04:30:58 CEST 2010
On Wed, Oct 27, 2010 at 9:13 PM, Chris Chandler
<chris at developingchris.com> wrote:
> 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 : 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
> CentralOH mailing list
> CentralOH at python.org
More information about the CentralOH