homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients belopolsky, facundobatista, r.david.murray, tim.peters
Date 2014年07月24日.19:01:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406228493.49.0.873968111331.issue22058@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014年07月24日 19:01:33tim.peterssetrecipients: + tim.peters, facundobatista, belopolsky, r.david.murray
2014年07月24日 19:01:33tim.peterssetmessageid: <1406228493.49.0.873968111331.issue22058@psf.upfronthosting.co.za>
2014年07月24日 19:01:33tim.peterslinkissue22058 messages
2014年07月24日 19:01:33tim.peterscreate

AltStyle によって変換されたページ (->オリジナル) /