[Python-ideas] Making datetime __str__ and isoformat more consistent

Masklinn masklinn at masklinn.net
Sat Nov 2 14:13:01 CET 2013


On 2013-11-02, at 02:52 , Andrew Barnert <abarnert at yahoo.com> wrote:

> On Nov 1, 2013, at 17:36, Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote:
> 
>> 
>> On Fri, Nov 1, 2013 at 8:28 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
>> What about just adding a fromisoformat classmethod constructor that's meant specifically for round tripping isoformat?
>> 
>> What about following the lead of int(), float(), etc. and allow datetime() take a single string argument? 
> 
> I have three (not entirely separate) concerns.
> 
> The first is that this would imply that ISO is _the_ format for datetimes, rather than just _a_ format. If you ask a normal person for an integer, unless he’s got the Super Bowl in the brain, int will parse his input.

Right, now try that with a float and watch `float(s)` blow up when most
europeans give you `4,63` or something along those lines.

Or ask for a large integer, and notice that int really does not like
decimal separators.



More information about the Python-ideas mailing list