[Python-ideas] date.datetime() method to convert from date to datetime
Evan Martin
python-dev at realityexists.net
Sat Jun 4 03:10:38 CEST 2011
On 4/06/2011 10:08 AM, Ben Finney wrote:
> Alexander Belopolsky
> <alexander.belopolsky at gmail.com> writes:
>
>> My preferred alternative to this idea would be to allow datetime
>> constructor to take date (or datetime). This would make date/datetime
>> behave similar to int/float.
> +1. They are conceptually very similar types, so it makes sense for the
> constructor to accept each of them.
I think that would work well if we had overloaded constructors, but
without them it might complicate things too much. What would the
signature look like?
Also, that would be inconsistent with how a datetime is converted to a
date - as a user I would then expect the date constructor to take a
datetime, too. If datetime.date() converts a datetime to a date then I
naturally think to call date.datetime() to go the other way.
--
Evan Martin
More information about the Python-ideas
mailing list