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 now `thedate` is a bona fide datetime.date
Or stick the two lines in a utility function.
If you're determined to do it one line, because datetime is a subclass of date
you could also use .combine() to force everything to class datetime.datetime in
one line:
_ZEROT = datetime.time()
def func(thedatetime):
thedatetime = datetime.combine(thedatetime, _ZEROT)
# and now `thedatetime` is a bona fide datetime.datetime
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22058>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com