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 belopolsky
Recipients belopolsky, facundobatista, r.david.murray, tim.peters
Date 2014-07-24.19:26:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1406229973.92.0.502135969485.issue22058@psf.upfronthosting.co.za>
In-reply-to
Content
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 that date/datetime do not accept their own instances often results in the need to branch on isinstance() or write a separate set of functions depending on whether dates are represented by numbers or by date instances.

The example that I gave is one of many and the fact that you suggested using isinstance() in the solution is telling. 

My ideal design would be for date/datetime constructors to take one argument that can be a string, a 3+ elements iterable, or any object that has a .timetuple() method.  The varargs variants can of course stay as syntactic sugar.
History
Date User Action Args
2014-07-24 19:26:13belopolskysetrecipients: + belopolsky, tim.peters, facundobatista, r.david.murray
2014-07-24 19:26:13belopolskysetmessageid: <1406229973.92.0.502135969485.issue22058@psf.upfronthosting.co.za>
2014-07-24 19:26:13belopolskylinkissue22058 messages
2014-07-24 19:26:13belopolskycreate