<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 25, 2017 at 4:22 PM, Alexander Belopolsky <span dir="ltr"><<a href="mailto:alexander.belopolsky@gmail.com" target="_blank">alexander.belopolsky@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">> times. The only difference is that instead of calling the type directly,<br>
> you call the appropriate classmethod.<br>
><br>
> What am I missing?<br>
<br>
</span>Nothing. The only annoyance is that the data processing code typically<br>
needs to know the type anyway, so the classmethod is one more variable<br>
to keep track of.</blockquote><div><br></div><div>I don't think anyone is arguing that is is hard to do either way, or that hard to use either way.</div><div><br></div><div>I think it comes down to a trade-off between:</div><div><br></div><div>Having an API for datetime that is like the datetime for number types:</div><div> </div><div><font face="monospace, monospace"> int(str(an_int)) == an_int</font></div><div><br></div><div> so:</div><div><br></div><div><font face="monospace, monospace"> datetime(str(a_datetime)) == a_datetime</font></div></div><div><br></div><div>Alexander strongly supports that.</div><div><br></div><div>Or an API that is perhaps more like the rest of the datetime api, which has a number of alternate constructors:</div><font face="monospace, monospace"><br> datetime.now()<br><br> datetime.fromordinal()   <br><br> datetime.fromtimestamp()</font><br><br></div><div class="gmail_extra">And has:</div><div class="gmail_extra"><br><font face="monospace, monospace">  datetime.isoformat()</font><div><br></div><div>So a</div><div><font face="monospace, monospace"><br></font></div><div>   <font face="monospace, monospace">datetime.fromisoformat()</font></div><div><br></div><div>would make a lot of sense.</div><div><br></div><div>I would note that the number types don't have all those alternate constructors Also, the number types mostly have a single parameter (except int has an optional base parameter). So I'm not sure the parallel is that strong.</div><div><br></div><div>Would it be horrible if we did both?</div><div><br></div><div>After all, right now, datetime has:</div><div><br></div><font face="monospace, monospace">In [16]: dt.isoformat()<br>Out[16]: '2017-10-25T16:30:48.744489'<br></font><br>and<font face="monospace, monospace"><br></font></div><div class="gmail_extra"><font face="monospace, monospace">In [18]: dt.__str__()<br>Out[18]: '2017-10-25 16:30:48.744489'<br></font><br></div><div class="gmail_extra">which do almost the same thing (I understand the "T" is option in iso 8601)</div><div class="gmail_extra"><br></div><div class="gmail_extra">However, maybe they are different when you add a time zone?</div><div class="gmail_extra"><br></div><div class="gmail_extra">ISO 8601 support offsets, but not time zones -- presumably the <font face="monospace, monospace">__str__</font> supports the full datetime tzinfo somehow. Which may be why<font face="monospace, monospace"> .isoformat()</font> exists.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Though I don't think that means you couldn't have the __init__ parse proper ISO strings, in addition to the full datetime __str__ results.</div><div class="gmail_extra"><br></div><div class="gmail_extra">-CHB</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">-- <br></div><div class="gmail_extra"><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>