Datetime has many methods that "serializes" an instance to some other format - toordinal, timestamp, isoformat, etc. Most methods that "serialize" a datetime have a corresponding method that "deserializes" that method, or another way to reverse the operation:
strftime / strptime
timestamp / fromtimestamp
isoformat / fromisoformat
toordinal / fromordinal
timetuple / datetime(*thetuple[0:6])
However, as I found out when implementing dateutil.parser.isoparse, there is no simple way to invert isocalendar().
I have an implementation as part of dateutil.parser.isoparse:
The attached PR is more or less fully ready, I think the correct answers to 1, 3 and 4 are that we should go with 3 separate arguments and we should not allow either time components or tz components, at least in this version.
In the future, I don't think it will be backwards incompatible to add in these features if they are desired (though I imagine they won't be terribly in demand, and it's pretty easy to work around).
The only real remaining question is number 2. Right now I am allowing keyword arguments, but the only real value I see in doing that is that PEP-570 (positional-only parameters) is not done yet and it's kind of annoying to implement "positional only parameters" in the pure Python version. If anyone feels strongly about this, let me know, otherwise I'll switch the implementation over to positional-only parameters.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
The text was updated successfully, but these errors were encountered: