Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Tim Peters
[Guido] > (I vaguely recall this has been brought up before, but I'm too lazy to find > the subtread. So it goes.) > > PEP 572 currently seems to specify that when used in expressions, the > precedence of `:=` is lower (i.e. it binds more tightly) Umm ... that's the opposite of what the Reference

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
On Wed, May 9, 2018 at 8:42 PM, Chris Angelico wrote: > On Thu, May 10, 2018 at 1:33 PM, Guido van Rossum > wrote: > > (I vaguely recall this has been brought up before, but I'm too lazy to > find > > the subtread. So it goes.) > > > > PEP 572 currently seems

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Chris Angelico
On Thu, May 10, 2018 at 1:33 PM, Guido van Rossum wrote: > (I vaguely recall this has been brought up before, but I'm too lazy to find > the subtread. So it goes.) > > PEP 572 currently seems to specify that when used in expressions, the > precedence of `:=` is lower (i.e. it

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Raymond Hettinger
On May 9, 2018, at 7:39 AM, Facundo Batista wrote: > > This way, I could do: > authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) > 'Authors: John, Mary, Estela' > ... > > What do you think? That is an inspired idea. I like it :-)

[Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
(I vaguely recall this has been brought up before, but I'm too lazy to find the subtread. So it goes.) PEP 572 currently seems to specify that when used in expressions, the precedence of `:=` is lower (i.e. it binds more tightly) than all operators except for the comma. I derive this from the

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Terry Reedy
On 5/9/2018 9:02 PM, Steven D'Aprano wrote: On Thu, May 10, 2018 at 10:50:13AM +1000, Chris Angelico wrote: On Thu, May 10, 2018 at 10:45 AM, Steven D'Aprano wrote: I too spent some time scratching my head trying to guess what you expect this "j" format code to do,

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Ken Kundert
Facundo, I think this is the beginning of a great feature. And it fills a hole in the current string formatting. Specifically, we can carefully control the formatting of the base data types, but not collections. I would like to see you flesh out the idea. In particular, I'd like to see

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Steven D'Aprano
On Thu, May 10, 2018 at 10:50:13AM +1000, Chris Angelico wrote: > On Thu, May 10, 2018 at 10:45 AM, Steven D'Aprano wrote: > > I too spent some time scratching my head trying to guess what you expect > > this "j" format code to do, including the fundamental question "why j >

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Chris Angelico
On Thu, May 10, 2018 at 10:45 AM, Steven D'Aprano wrote: > I too spent some time scratching my head trying to guess what you expect > this "j" format code to do, including the fundamental question "why j > and not some other letter?". Interestingly, that question didn't faze

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Steven D'Aprano
On Wed, May 09, 2018 at 04:56:38PM -0300, Facundo Batista wrote: > 2018-05-09 13:48 GMT-03:00 Rhodri James : > > > -1 until you give me an actual spec rather than a curious example. > > > > Sorry if that sounds a bit rude, but I spend most of my time trying to find > > Be

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Facundo Batista
2018-05-09 13:48 GMT-03:00 Rhodri James : > -1 until you give me an actual spec rather than a curious example. > > Sorry if that sounds a bit rude, but I spend most of my time trying to find Be sorry, it was rude. This list is for throwing ideas and see if they gain

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Rhodri James
On 09/05/18 13:39, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors: John, Mary, Estela' In this case the join can be made in the format yes, but this proposal would be very useful when the info to format comes

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-09 Thread Tim Peters
... [Guido] >> We should probably define what happens when you write [p := p for p in >> range(10)]. I propose that this overwrites the loop control variable rather >> than creating a second p in the containing scope -- either way it's probably >> a typo anyway. [Jacco van Dorp

Re: [Python-ideas] Please consider skipping hidden directories in os.walk, os.fwalk, etc.

2018-05-09 Thread Nathaniel Smith
There are hidden directories, and then there are hidden directories :-). It makes sense to me to add an option to the stdlib functions to skip directories (and files) that the system considers hidden, so I guess that means dotfiles on Unix and files with the hidden attribute on Windows. But if you

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Paul Moore
On 9 May 2018 at 15:29, Eric V. Smith wrote: > On 5/9/18 10:01 AM, Paul Moore wrote: >> >> On 9 May 2018 at 14:49, Eric V. Smith wrote: >>> >>> I would object to changing the format machinery. Any format spec should >>> be >>> interpreted by some object's

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 10:01 AM, Paul Moore wrote: On 9 May 2018 at 14:49, Eric V. Smith wrote: I would object to changing the format machinery. Any format spec should be interpreted by some object's __format__ method. Agreed. In theory this is a nice idea, but the way formatting is

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Paul Moore
On 9 May 2018 at 14:49, Eric V. Smith wrote: > On 5/9/18 9:28 AM, Chris Angelico wrote: >> On Wed, May 9, 2018 at 11:06 PM, Steven D'Aprano >> wrote: >> >>> - do you truly mean lists *only*, or is any iterable acceptible? >> >> With the letter being "j"

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 9:28 AM, Chris Angelico wrote: On Wed, May 9, 2018 at 11:06 PM, Steven D'Aprano wrote: On Wed, May 09, 2018 at 09:39:08AM -0300, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors:

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Eric V. Smith
On 5/9/18 8:39 AM, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors: John, Mary, Estela' In this case the join can be made in the format yes, but this proposal would be very useful when the info to format comes

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Chris Angelico
On Wed, May 9, 2018 at 11:06 PM, Steven D'Aprano wrote: > On Wed, May 09, 2018 at 09:39:08AM -0300, Facundo Batista wrote: >> This way, I could do: >> >> >>> authors = ["John", "Mary", "Estela"] >> >>> "Authors: {:, j}".format(authors) >> 'Authors: John, Mary, Estela' > > > >

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Wolfgang Maier
On 05/09/2018 02:39 PM, Facundo Batista wrote: This way, I could do: authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) 'Authors: John, Mary, Estela' In this case the join can be made in the format yes, but this proposal would be very useful when the info to format comes

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Steven D'Aprano
On Wed, May 09, 2018 at 09:39:08AM -0300, Facundo Batista wrote: > This way, I could do: > > >>> authors = ["John", "Mary", "Estela"] > >>> "Authors: {:, j}".format(authors) > 'Authors: John, Mary, Estela' Looks interesting, but I think we need to know the semantics in more detail. For

Re: [Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Joao S. O. Bueno
On 9 May 2018 at 09:39, Facundo Batista wrote: > This way, I could do: > authors = ["John", "Mary", "Estela"] "Authors: {:, j}".format(authors) > 'Authors: John, Mary, Estela' +1. I bit concerned about the relevant whitespace in there, but just a little bit -

[Python-ideas] Have a "j" format option for lists

2018-05-09 Thread Facundo Batista
This way, I could do: >>> authors = ["John", "Mary", "Estela"] >>> "Authors: {:, j}".format(authors) 'Authors: John, Mary, Estela' In this case the join can be made in the format yes, but this proposal would be very useful when the info to format comes inside a structure together with other

Re: [Python-ideas] Please consider skipping hidden directories in os.walk, os.fwalk, etc.

2018-05-09 Thread Wes Turner
fnmatch.filter does Unix filename pattern matching. https://docs.python.org/3/library/fnmatch.html#fnmatch.filter grin and grind are like grep and find with options to filter hidden files and VCS directories by default. https://pypi.org/project/grin/ There's an example of using the Python API

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-09 Thread Jacco van Dorp
My apologies for something unclear in my previous mail - the second block I quoted (the one without a name) originated from Guido, not from Tim. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] Please consider skipping hidden directories in os.walk, os.fwalk, etc.

2018-05-09 Thread Steve Barnes
On 08/05/2018 15:53, Giampaolo Rodola' wrote: > > > On Tue, May 8, 2018 at 2:00 PM, David Mertz > wrote: > > I like the idea. I think an argument to os.walk() is the simplest > option for most users. But per some comments, "hidden" is

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-09 Thread Jacco van Dorp
> [Tim] > {About binding the for loop variable} Yeah, that binding is the one I attempted to refer to. So I did understand you after all. > We should probably define what happens when you write [p := p for p in > range(10)]. I propose that this overwrites the loop control variable rather > than