Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Nathan Schneider
On Sun, Mar 4, 2018 at 11:04 PM, Chris Angelico wrote: > On Mon, Mar 5, 2018 at 2:49 PM, Mike Miller > wrote: > > Yes, thanks: > > > > [ f(y), g(y) for x, h(x) as y in things ] > > > > > > Dyslexics untie! > > :) > > Hmm. The trouble here is that

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Chris Angelico
On Mon, Mar 5, 2018 at 2:49 PM, Mike Miller wrote: > Yes, thanks: > > [ f(y), g(y) for x, h(x) as y in things ] > > > Dyslexics untie! :) Hmm. The trouble here is that a 'for' loop is basically doing assignment. When you say "for x, h(x) as y in things", what

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Mike Miller
Yes, thanks: [ f(y), g(y) for x, h(x) as y in things ] Dyslexics untie! On 2018-03-04 19:45, Chris Angelico wrote: ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Chris Angelico
On Mon, Mar 5, 2018 at 2:39 PM, Mike Miller wrote: > > On 2018-03-03 16:51, Greg Ewing wrote: >>> >>> 2018-03-03 8:40 GMT+01:00 Nick Coghlan : pairs = [(f(y), g(y)) for x in things with bind(h(x)) as y] >> >> >> I don't mucn like "with

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Mike Miller
On 2018-03-03 16:51, Greg Ewing wrote: 2018-03-03 8:40 GMT+01:00 Nick Coghlan :    pairs = [(f(y), g(y)) for x in things with bind(h(x)) as y] I don't mucn like "with bind(h(x)) as y" because it's kind of like an abstraction inversion -- you're building something

Re: [Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Steven D'Aprano
On Sun, Mar 04, 2018 at 12:11:16PM -0800, Michel Desmoulin wrote: > But, first, they are not common enough so that it's hard to do: > > spam = docs.python.org" > eggs = 'wiki.' + '.'.join(spams.split('.')[1:]) In a more realistic case, the delimiter is not necessarily a constant, nor will you

Re: [Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Steven D'Aprano
On Sun, Mar 04, 2018 at 01:44:20PM -0500, Clint Hepner wrote: > -1. I see no compelling reason to overload __getitem__ to provide a synonym > for the split method. > > eggs = "wiki." + spam.split('.')[1:] Fair point. Neither do I. But your next comment: > Besides, you can already make

Re: [Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Michel Desmoulin
Even if replace would be a better fit, I can see why doing those 3 operations in one row can be valuable. But, first, they are not common enough so that it's hard to do: spam = docs.python.org" eggs = 'wiki.' + '.'.join(spams.split('.')[1:]) It's not that long to type, and certainly is not

Re: [Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Clint Hepner
> On 2018 Mar 4 , at 12:59 p, Andrés Delfino wrote: > > Hi! > > I was thinking: perhaps it would be nice to be able to quicky split a string, > do some slicing, and then obtaining the joined string back. > > Say we have the string: "docs.python.org", and we want to change

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Robert Vanden Eynde
> I know Guido is on record as not wanting to allow both "for name in > sequence" and "for name = expr" due to that being a very subtle distinction > between iteration and simple assignment (especially given that Julia uses > them as alternate spellings for the same thing), but I'm wondering if it

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Robert Vanden Eynde
> What the heck, if it was good enough for PL/1... It would still be parsable indeed. A keyword available in a context would then be something new in the language. > Choice of syntax is important, though. It's all very well > to come up with an "insert syntax here" proposal that has > some big

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Robert Vanden Eynde
> Robert Vanden Eynde wrote: >> >> But I think that the implementation of print(y with y = x + 1) would >> be more close to next(y for y in [ x+1 ]) > > > WHy on earth should it be? Expanding that gives you a generator > containing a loop that only executes once that is immediately run > to yield

[Python-ideas] Split, slice, join and return "syntax" for str

2018-03-04 Thread Andrés Delfino
Hi! I was thinking: perhaps it would be nice to be able to quicky split a string, do some slicing, and then obtaining the joined string back. Say we have the string: "docs.python.org", and we want to change "docs" to "wiki". Of course, there are a ton of simpler ways to solve this particular

Re: [Python-ideas] Class autoload

2018-03-04 Thread Nick Coghlan
On 4 March 2018 at 03:42, Chris Angelico wrote: > On Sun, Mar 4, 2018 at 4:12 AM, Jamesie Pic wrote: > > > > Hello everybody, > > > > I thought perhaps we could allow the usage of a "new" keyword to > instanciate > > an object, ie: > > > >obj = new

Re: [Python-ideas] Class autoload

2018-03-04 Thread Stephen J. Turnbull
Jamesie Pic writes: > obj = new yourmodule.YourClass() I don't understand what this is good for. Keeping up with PHP is not something that is a goal for Python. Borrowing useful features is definitely an idea, but you need to explain why it's useful. I also don't understand why you call this

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Stephen J. Turnbull
Nick Coghlan writes: > pairs = [(f(y), g(y)) for x in things with y = h(x)] > contents = [f.read() for fname in filenames with open(fname) as f] This is horrible. I think Julia is just weird: in normal English we do distinguish between equality and membership. "x in y" is a very

Re: [Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

2018-03-04 Thread Stephen J. Turnbull
Soni L. writes: > [(lambda y: (f(y), g(y)))(h(x)) for x in things] ? MicroLisp? ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-04 Thread Stephen J. Turnbull
Chris Angelico writes: > > So what happens to rejected alternatives when the PEP itself is rejected? > > ;) > > > > Algebraically, they must be accepted. Right? That's not how de Moivre's laws work. ;-) ___ Python-ideas mailing list