Paul Ganssle <p.gans...@gmail.com> added the comment:

>  I can see your point in not causing confusion about what this method is 
> meant to be used for.

In this case, making it easy to explain what it does is less important than 
making the scope and contract of the function clear so that we don't have to 
argue about what should and should not be supported. Having a narrowly-scoped 
function is also useful for other reasons:

1. The API is clearer - there are no options to configure on this function, if 
you start supporting a bunch of features, people will inevitably want to turn 
some of them *off*, because they only want to accept a subset of the valid 
inputs.

2. The interface to test is clear - we can exhaustively test the entire 
contract of the function if desired.

3. Development will not get stalled in decision-making about which features to 
support or how they might interfere with one another.

> From a cursory glance at the RFC3339 spec it looks like the only other change 
> needed to fully support RFC3339 would be to support an arbitrary number of 
> sub-second digits, whereas fromisoformat() currently requires either exactly 
> 3 or 6.

There are other differences, for example a comma can be used in place of a dot 
as the delimiter for fractional seconds. Looking at the grammar in the RFC, it 
seems that it might also support datetimes like 2018-W03-D4, but I don't see 
any mention of that in the text.

> So, I can bundle this together with a change making it more lenient about the 
> number of decimal places for seconds, and we can change the docs for 
> `fromisoformat()` to be "it accepts any RFC3339 timestamp, including those 
> generated by isoformat()".

No, because the isoformat outputs are not a subset of RFC 3339. For example, 
2015-01-01T00:00:00 is not a valid RFC 3339 datetime string, nor is 
2015-01-01Q00:00:00, but they are valid outputs of datetime.isoformat(). 
datetime.fromisoformat() also supports fractional seconds on time zone offsets, 
which is not part of ISO 8601.

> Because what I'm trying to use it for technically falls outside the intended 
> use, I say it would make the most sense to expand the intended use a bit. 

Is there a reason you can't use `dateutil.parser.isoparse`? The contract of 
that function is to parse any valid ISO8601 datetime, and fromisoformat is 
adapted from it.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35829>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to