Re: [Python-Dev] iso8601 parsing

2017-12-08 Thread Chris Barker - NOAA Federal
On Dec 7, 2017, at 7:52 PM, Mike Miller wrote: Guess the argument for limiting what it accepts would be that every funky variation will need to be supported until the endtimes, even those of little use or utility. I suppose so, but not that hard once implemented and tests in place. How about t

Re: [Python-Dev] iso8601 parsing

2017-12-07 Thread Mike Miller
Guess the argument for limiting what it accepts would be that every funky variation will need to be supported until the endtimes, even those of little use or utility. On the other hand, it might be good to keep the two implementations the same for consistency reasons. Thanks either way, -Mik

Re: [Python-Dev] iso8601 parsing

2017-12-07 Thread Chris Barker - NOAA Federal
>but is it that hard to parse arbitrary ISO8601 strings in once you've gotten this far? It's a bit uglier than I'd like, but not THAT bad a spec. No, and in fact this PR is adapted from a *more general* ISO-8601 parser that I wrote (which is now merged into master on python-dateutil). In the CP

Re: [Python-Dev] iso8601 parsing

2017-12-07 Thread Paul G
> And I'm sorry, I got a bit lost in the PR, but you are attaching an > "offset" tzinfo, when parsing an iso string that has one, yes? Yes, a fixed offset time zone (since the original zone information is lost): >>> from dateutil import tz >>> from datetime import datetime >>> datetim

Re: [Python-Dev] iso8601 parsing

2017-12-07 Thread Chris Barker
On Wed, Dec 6, 2017 at 3:07 PM, Paul Ganssle wrote: > Here is the PR I've submitted: > > https://github.com/python/cpython/pull/4699 > > The contract that I'm supporting (and, I think it can be argued, the only > reasonable contract in the intial implementation) is the following: > > dtstr =

Re: [Python-Dev] iso8601 parsing

2017-12-06 Thread Paul Ganssle
Here is the PR I've submitted: https://github.com/python/cpython/pull/4699 The contract that I'm supporting (and, I think it can be argued, the only reasonable contract in the intial implementation) is the following: dtstr = dt.isoformat(*args, **kwargs) dt_rt = datetime.fromisoformat(d

Re: [Python-Dev] iso8601 parsing

2017-12-06 Thread Barry Scott
> On 26 Oct 2017, at 17:45, Chris Barker wrote: > > This is a key point that I hope is obvious: > > If an ISO string has NO offset or timezone indicator, then a naive datetime > should be created. > > (I say, I "hope" it's obvious, because the numpy datetime64 implementation > initially (an

Re: [Python-Dev] iso8601 parsing

2017-12-01 Thread Alexander Belopolsky
> is there a strict deadline here if we want this for Python 3.7? The deadline for the new features is the date of the first beta currently scheduled for 2018-01-29, but if you can get this in before the last alpha (2018-01-08) it will be best. See PEP 537 (https://www.python.org/dev/peps/pep-053

Re: [Python-Dev] iso8601 parsing

2017-12-01 Thread Paul G
As an update, I have the C version done and basically tested as an extension (I "cheated" on the tests by using hypothesis, so I still need to write unittest-style tests), just writing the Python version with tests now. I know there is a feature freeze coming in soon, is there a strict deadline

Re: [Python-Dev] iso8601 parsing

2017-12-01 Thread Chris Barker
On Wed, Nov 29, 2017 at 4:19 PM, Paul G wrote: > I can write at least a pure Python implementation in the next few days, if > not a full C implementation. Shouldn't be too hard since I've got a few > different Cython implementations sitting around anyway. > > Thanks! -CHB > On November 29, 2

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Alexander Belopolsky
On Wed, Nov 29, 2017 at 7:18 PM, Mario Corchero wrote: > There were discussions about having it a function, making the constructor > of datetime accept a string(this was strongly rejected), having a static > function in datetime, etc... and there was no real agreement. > Guido has written severa

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Mike Miller
Yeah! I'm available for writing docs and testing it if needed. Performance is not a big concern in this first version, unless you've already written most of it. If it is a concern for others then the third-party modules will still be available as well. -Mike On 2017-11-29 16:19, Paul G wr

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Paul G
I can write at least a pure Python implementation in the next few days, if not a full C implementation. Shouldn't be too hard since I've got a few different Cython implementations sitting around anyway. On November 29, 2017 7:06:58 PM EST, Alexander Belopolsky wrote: >On Wed, Nov 29, 2017 at 6

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Mario Corchero
There were discussions about having it a function, making the constructor of datetime accept a string(this was strongly rejected), having a static funcion in datetime, etc... and there was no real agreement. If the agreement is that we want a funcion to be able to parse it I am sure Paul G will be

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Alexander Belopolsky
On Wed, Nov 29, 2017 at 6:42 PM, Chris Barker wrote: > > indeed what is the holdup? I don't recall anyone saying it was a bad idea > in the last discussion. > > Do we just need an implementation? > > Is the one in the Bug Report not up to snuff? If not, then what's wrong > with it? This is just n

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Chris Barker
On Wed, Nov 29, 2017 at 10:05 AM, Mike Miller wrote: > This thread isn't about the numerous third-party solutions that are a pip > command away. But rather getting a minimal return parser to handle > datetime.isoformat() into the std library. > > It's been needed for years, indeed what is the

Re: [Python-Dev] iso8601 parsing

2017-11-29 Thread Mike Miller
Hi, This thread isn't about the numerous third-party solutions that are a pip command away. But rather getting a minimal return parser to handle datetime.isoformat() into the std library. It's been needed for years, and hopefully someone can squeeze it into 3.7 before its too late. (It tak

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Mario Corchero
The basics should be possible already with issue31800 , that said the issue you reference is to get a single function to parse it (without having to put the whole format), which would be neat. I believe Paul Ganssle is planning on adding it to dateutil as well:

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Skip Montanaro
It's got its own little parsing language, different than the usual strftime/strptime format scheme, more like what you might see in Excel. I never worried too much about the speed of dateutil.parser.parse() unless I was calling it in an inner loop, but arrow.get() seems to be a fair bit faster than

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Paul G
IIRC, arrow usually calls dateutil to parse dates anyway, and there are many other, lighter dependencies that will parse an ISO 8601 date quickly into a datetime.datetime object. I still think it's reasonable for the .isoformat() operation to have an inverse operation in the standard library.

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Skip Montanaro
> I think the latest version can now strptime offsets of the form ±HH:MM with > %z, so there's no longer anything blocking you from parsing from all > isoformat() outputs with strptime, provided you know which one you need. Or just punt and install arrow: >>> import arrow >>> arrow.get('2017-10-2

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Paul G
I think the latest version can now strptime offsets of the form ±HH:MM with %z, so there's no longer anything blocking you from parsing from all isoformat() outputs with strptime, provided you know which one you need. I think a from_isoformat() like method that *only* supports isoformat outputs

Re: [Python-Dev] iso8601 parsing

2017-11-28 Thread Mike Miller
This may have gotten bogged down again. Could we get the output of datetime.isoformat() parsed at a minimum? Perfection is not required. Looks like there is a patch or two and test cases on the bug. -Mike Could anyone put this five year-old bug about parsing iso8601 format date-times on th

Re: [Python-Dev] iso8601 parsing

2017-10-26 Thread Wes Turner
On Thursday, October 26, 2017, Chris Barker wrote: > On Wed, Oct 25, 2017 at 7:37 PM, Wes Turner > wrote: > >> ISO 8601 support offsets, but not time zones -- presumably the __str__ >>> supports the full datetime tzinfo somehow. Which may be why .isoformat() >>> exists. >>> >> >> ISO8601 does su

Re: [Python-Dev] iso8601 parsing

2017-10-26 Thread Alex Walters
From: Python-Dev [mailto:python-dev-bounces+tritium-list=sdamon@python.org] On Behalf Of Chris Barker Sent: Thursday, October 26, 2017 12:46 PM To: Wes Turner Cc: Python-Dev Subject: Re: [Python-Dev] iso8601 parsing > No, it doesn't -- it may call them "timezones&

Re: [Python-Dev] iso8601 parsing

2017-10-26 Thread Chris Barker
On Wed, Oct 25, 2017 at 7:37 PM, Wes Turner wrote: > ISO 8601 support offsets, but not time zones -- presumably the __str__ >> supports the full datetime tzinfo somehow. Which may be why .isoformat() >> exists. >> > > ISO8601 does support timezones. > https://en.wikipedia.org/wiki/ISO_8601#Time_z

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Nick Coghlan
On 26 October 2017 at 07:30, Chris Barker wrote: > +1 on a classmethod constructor > +0 on a based-on-type default constructor > > +inf on SOMETHING! > > Let's get passed the bike shedding and make this work! > I'll also note that these aren't either/or outcomes: adding a str-specific classmetho

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Fred Drake
On Wed, Oct 25, 2017 at 10:37 PM, Wes Turner wrote: > What would you call the str argument? Does it accept strptime args or only > ISO8601? There'd be no reason to accept a format. That wouldn't make sense. A .fromiso(s:str) should only accept an ISO 8601 string, though I'd advocate tolerating

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Wes Turner
On Wednesday, October 25, 2017, Chris Barker wrote: > On Wed, Oct 25, 2017 at 4:22 PM, Alexander Belopolsky < > alexander.belopol...@gmail.com > > wrote: > >> > times. The only difference is that instead of calling the type directly, >> > you call the appropriate classmethod. >> > >> > What am I

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Guido van Rossum
I think this ship has long sailed. Sorry Alexander, but I see a new class method in your future. -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Chris Barker
On Wed, Oct 25, 2017 at 4:22 PM, Alexander Belopolsky < alexander.belopol...@gmail.com> wrote: > > times. The only difference is that instead of calling the type directly, > > you call the appropriate classmethod. > > > > What am I missing? > > Nothing. The only annoyance is that the data processi

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alexander Belopolsky
On Wed, Oct 25, 2017 at 5:30 PM, Chris Barker wrote: > Let's get passed the bike shedding and make this work! Sure. Submitting a pull request for would be a good start. ___ Python-Dev mailing list Python-Dev@python

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alexander Belopolsky
On Wed, Oct 25, 2017 at 5:30 PM, Steven D'Aprano wrote: > Maybe I'm just being slow today, but I don't see how you can write > "generic code" to convert text to int/float/complex/Fraction, but not > times. The only difference is that instead of calling the type directly, > you call the appropriate

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Steven D'Aprano
On Wed, Oct 25, 2017 at 04:32:39PM -0400, Alexander Belopolsky wrote: > On Wed, Oct 25, 2017 at 3:48 PM, Alex Walters wrote: > > Why make parsing ISO time special? > > It's not the ISO format per se that is special, but parsing of str(x). > For all numeric types, int, float, complex and even > f

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Chris Barker
m: Alexander Belopolsky [mailto:alexander.belopol...@gmail.com] > > Sent: Wednesday, October 25, 2017 4:33 PM > > To: Alex Walters > > Cc: Elvis Pranskevichus ; Python-Dev > d...@python.org>; Chris Barker > > Subject: Re: [Python-Dev] iso8601 parsing > > > > On Wed, Oct 25,

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Random832
On Wed, Oct 25, 2017, at 16:32, Alexander Belopolsky wrote: > This is annoying when you deal with time > series where it is common to have text files with a mix of dates, > timestamps and numbers. You can write generic code to deal with ints > and floats, but have to special-case anything time rel

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alex Walters
> -Original Message- > From: Alexander Belopolsky [mailto:alexander.belopol...@gmail.com] > Sent: Wednesday, October 25, 2017 4:33 PM > To: Alex Walters > Cc: Elvis Pranskevichus ; Python-Dev d...@python.org>; Chris Barker > Subject: Re: [Python-Dev] iso8601 par

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alexander Belopolsky
On Wed, Oct 25, 2017 at 3:48 PM, Alex Walters wrote: > Why make parsing ISO time special? It's not the ISO format per se that is special, but parsing of str(x). For all numeric types, int, float, complex and even fractions.Fraction, we have a roundtrip invariant T(str(x)) == x. Datetime types ar

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alex Walters
> -Original Message- > From: Python-Dev [mailto:python-dev-bounces+tritium- > list=sdamon@python.org] On Behalf Of Elvis Pranskevichus > Sent: Tuesday, October 24, 2017 8:12 PM > To: python-dev@python.org > Cc: Chris Barker > Subject: Re: [Python-Dev] iso8601 pa

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alex Walters
> -Original Message- > From: Alexander Belopolsky [mailto:alexander.belopol...@gmail.com] > Sent: Wednesday, October 25, 2017 12:07 PM > To: Alex Walters > Cc: Chris Barker ; Python-Dev d...@python.org> > Subject: Re: [Python-Dev] iso8601 parsing > > >

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alexander Belopolsky
> On Oct 25, 2017, at 11:45 AM, Alex Walters wrote: > > it means > the type of the first argument changes the semantic meaning of subsequent > arguments, and that just adds a level of confusion to any api. No, it does not. Passing a string a the first of three arguments will still be a type e

Re: [Python-Dev] iso8601 parsing

2017-10-25 Thread Alex Walters
> -Original Message- > From: Python-Dev [mailto:python-dev-bounces+tritium- > list=sdamon@python.org] On Behalf Of Alexander Belopolsky > Sent: Tuesday, October 24, 2017 5:54 PM > To: Chris Barker > Cc: Python-Dev > Subject: Re: [Python-Dev] iso8601 parsin

Re: [Python-Dev] iso8601 parsing

2017-10-24 Thread Elvis Pranskevichus
On Tuesday, October 24, 2017 5:53:58 PM EDT Alexander Belopolsky wrote: > No, but the last time I suggested that that datetime types should > satisfy the same invariants as numbers, namely > T(repr(x)) == x, the idea was met will silence. I, on the other hand, > am not very enthusiastic about name

Re: [Python-Dev] iso8601 parsing

2017-10-24 Thread Alexander Belopolsky
On Tue, Oct 24, 2017 at 5:26 PM, Chris Barker wrote: > On Mon, Oct 23, 2017 at 5:33 PM, Hasan Diwan wrote: >> > can anyone argue that it's not a good idea for datetime ot > be able to read the iso format it puts out? No, but the last time I suggested that that datetime types should satisfy the s

Re: [Python-Dev] iso8601 parsing

2017-10-24 Thread Chris Barker
On Mon, Oct 23, 2017 at 5:33 PM, Hasan Diwan wrote: > If one simply replaces the 'T' with a space and trims it after the '.', > IIRC, it parses fine. > sure, but really, can anyone argue that it's not a good idea for datetime ot be able to read the iso format it puts out??? -CHB > -- H > > O

Re: [Python-Dev] iso8601 parsing

2017-10-23 Thread Hasan Diwan
If one simply replaces the 'T' with a space and trims it after the '.', IIRC, it parses fine. -- H On Oct 23, 2017 15:16, "Mike Miller" wrote: > Hi, > > Could anyone put this five year-old bug about parsing iso8601 format > date-times on the front burner? > > http://bugs.python.org/issue1587

[Python-Dev] iso8601 parsing

2017-10-23 Thread Mike Miller
Hi, Could anyone put this five year-old bug about parsing iso8601 format date-times on the front burner? http://bugs.python.org/issue15873 In the comments there's a lot of hand-wringing about different variations that bogged it down, but right now I only need it to handle the output of