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
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
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:
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
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
> 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
> 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
> 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
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
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/
Robert Vanden Eynde wrote:
The "make it a keyword in a context" might lead to things like
"print(where where where = where)", not sure you'd want that :)
What the heck, if it was good enough for PL/1...
But that's just a choice of syntax,
Choice of syntax is important, though. It's all
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
complicated on top of something complicated in
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 exactly one
Nathan Goldbaum wrote:
Where is also very common in numpy. So if someone did:
from numpy import *
data = where(condition)
They might have issues
Bummer, I didn't know numpy used it. That puts rather a big
dampener on the idea of making it a keyword. :-(
Remaining options include:
* Make
Robert Vanden Eynde wrote:
One could see :
print(y with y = x+1)
As a shortcut for :
print(next(y for y in [ x+1 ]))
Or more straightforwardly,
print((lambda y: y)(x + 1))
This is how the semantics of let-type constructs is
often defined in lambda-calculus-inspired languages
such as
On Sat, Mar 3, 2018 at 5:12 AM Oleg Broytman wrote:
> On Sat, Mar 03, 2018 at 02:36:39PM +1300, Greg Ewing <
> greg.ew...@canterbury.ac.nz> wrote:
> >[(f(y), g(y)) for x in things where y = h(x)]
> >
> > Possible objections to this:
> >
> > * Requires a new keyword, which
Le 3 mars 2018 08:45, "Nick Coghlan" a écrit :
On 3 March 2018 at 11:36, Greg Ewing wrote:
> 1. Name bindings local to an expression:
>
>roots = ([(-b-r)/(2*a), (-b+r)/(2*a)] where r = sqrt(b*b-4*a*c))
>
> B. In an expression, surrounded by
On 2018-03-03 08:09 AM, Oleg Broytman wrote:
On Sat, Mar 03, 2018 at 02:36:39PM +1300, Greg Ewing
wrote:
[(f(y), g(y)) for x in things where y = h(x)]
Possible objections to this:
* Requires a new keyword, which may break existing code.
- Yes, but "where"
On 3 March 2018 at 07:45, Nick Coghlan wrote:
> On 3 March 2018 at 11:36, Greg Ewing wrote:
>>
>> 1. Name bindings local to an expression:
>>
>>roots = ([(-b-r)/(2*a), (-b+r)/(2*a)] where r = sqrt(b*b-4*a*c))
>>
>> B. In an expression,
On 3 March 2018 at 11:36, Greg Ewing wrote:
> 1. Name bindings local to an expression:
>
>roots = ([(-b-r)/(2*a), (-b+r)/(2*a)] where r = sqrt(b*b-4*a*c))
>
> B. In an expression, surrounded by parentheses for
> disambiguation. Bindings are visible only within
On 3 March 2018 at 11:36, Greg Ewing wrote:
> PEP 572 as it stands seems to have many problems:
>
> * Asymmetry between the first and subsequent
> uses of the bound value
> * Embedded as-clauses are subtle and hard to spot
> * Ever more convoluted semantics are
The syntax you propose is already in the Alternate syntax and there is an
implementation at https://github.com/thektulu/cpython/tree/where-expr
Already discussed, but no conclusion, for me I see two different proposals,
the "[y for x in range(5) with y = x+1]" in comprehensions list, and the
case
PEP 572 as it stands seems to have many problems:
* Asymmetry between the first and subsequent
uses of the bound value
* Embedded as-clauses are subtle and hard to spot
* Ever more convoluted semantics are being invented
to address percieved pitfalls
Alternative proposal
23 matches
Mail list logo