[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: [David] > There is already a spelling for that operation, and it is d.date() [Tim] Alexander, I don't see a need to make everything a one-liner [Facundo] > So, unless anyody wants to pursue with this, I'll close the issue. Marking as closed, rejected for th

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Facundo Batista
Facundo Batista added the comment: El 24/07/14 a las 15:01, Tim Peters escibió: > "datetime.date() should accept a datetime.datetime as init > parameter" > > instead? That's what the example appears to be getting at. > > If so, -1. Datetime objects already have .date(), .time(), and > .timet

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It is not as mush about avoiding a one-liner as it is about duck-typing. IMO, dates and datetime objects are numbers in disguise. Many functions that are nominally numeric, can work with date/datetime/timedelta objects without modification. The fact t

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Tim Peters
Tim Peters added the comment: Alexander, I don't see a need to make everything a one-liner. Dealing with a mix of dates and datetimes is easily sorted out with an `if` statement, like def func(thedate): if isinstance(thedate, datetime.datetime): thedate = thedate.date() # and n

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Another "solution" is date(2001, 1, 1).__lt__(x), but this is even uglier than the one with timetuple. -- ___ Python tracker ___

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > some_datetime_object.date() is the obvious way to extract a > date object from a datetime object. Sorry if I was not clear enough about my use case. I often have to deal with functions that are designed to take either date or datetime object as an arg

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Tim Peters
Tim Peters added the comment: Was the title of this meant to be "datetime.date() should accept a datetime.datetime as init parameter" instead? That's what the example appears to be getting at. If so, -1. Datetime objects already have .date(), .time(), and .timetz() methods to extract, respe

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: +1 There is currently no obvious way to convert either date or datetime instance to date. The best solution I can think of is date(*x.timetuple()[:3]): >>> d = date.today() >>> t = datetime.now() >>> date(*d.timetuple()[:3]) datetime.date(2014, 7, 24) >

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread R. David Murray
R. David Murray added the comment: There is already a spelling for that operation, and it is d.date(). I'm not sure that there is a strong enough argument for adding a second way to spell it, but I won't close this yet to see what other people think. Personally I don't think it has ever occ

[issue22058] datetime.datetime() should accept a datetime.date as init parameter

2014-07-24 Thread Facundo Batista
Changes by Facundo Batista : -- title: datetime.datetime() should accept a datetime.date as constructor -> datetime.datetime() should accept a datetime.date as init parameter ___ Python tracker ___