Abdulla Al Kathiri wrote:
> Oh I forgot what if you want to return a set from your lambda? Maybe a lambda
> set should at least have one assignment statement to qualify it as one.
> Expressions only inside a set syntax will be just a normal set that doesn’t
> care about order as you pointed out.
Oh I forgot what if you want to return a set from your lambda? Maybe a lambda
set should at least have one assignment statement to qualify it as one.
Expressions only inside a set syntax will be just a normal set that doesn’t
care about order as you pointed out. But a lambda set will care about
I'm somewhat confused by the term "last item of the set", as sets are not
ordered and have no "last" element:
>>> {1,3,3,2}
{1, 2, 3}
On Sat, Oct 2, 2021 at 8:23 PM Abdulla Al Kathiri <
alkathiri.abdu...@gmail.com> wrote:
> Then use it with the normal expression lambda:
> people.sort(key=p => (p
Then use it with the normal expression lambda:
people.sort(key=p => (p.salary, p.name, p.id)).
You don’t need lambda set for that. If you want to use it, it will be like the
following:
people.sort(key=p => {(p.salary, p.name, p.id)}). The tuple expression is the
last item of the set, so the tu
On 2021-09-29 10:11, MRAB wrote:
I'd prefer something like "x -> x" "x => x" as an equivalent to "lambda
x: x":
I continue to find all such syntaxes less readable even than lambda.
The idea of using a hyphen and a greater-than sign to "draw" an arrow
doesn't sit well with me.
The only pro
On Sun, Oct 3, 2021 at 9:04 AM Abdulla Al Kathiri
wrote:
>
> Yeah empty parentheses for parameters-less function is the clear obvious way.
> Optional parenthesis for single parameter function is a wise choice. In fact,
> I read C# lambdas and they made really great design choices. I particularl
Yeah empty parentheses for parameters-less function is the clear obvious way.
Optional parenthesis for single parameter function is a wise choice. In fact, I
read C# lambdas and they made really great design choices. I particularly like
the statements lambda. How about doing it in Python with t
On 2021-10-02 08:59, Abdulla Al Kathiri wrote:
Let’s say I want to write a lambda function with no arguments that’s connected to a
button in GUI coding, will blabla.connect(()=>print(“clicked”)) be used or will
blabla.connect(=>print(“clicked”)) be used?
In the case of C#, the parentheses are
Let’s say I want to write a lambda function with no arguments that’s connected
to a button in GUI coding, will blabla.connect(()=>print(“clicked”)) be used or
will blabla.connect(=>print(“clicked”)) be used?
Sent from my iPhone
> On 30 Sep 2021, at 7:53 PM, MRAB wrote:
>
> On 2021-09-30 07:
> Being too terse is worse than being too verbose
This is my view as well. I would not want to see python go Perl-shaped.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.
On 2021-09-30 07:21, Chris Angelico wrote:
On Thu, Sep 30, 2021 at 4:19 PM Steven D'Aprano wrote:
On Wed, Sep 29, 2021 at 02:09:03PM -0700, Guido van Rossum wrote:
> Over in typing-sig we're considering a new syntax for callable *types*,
> which would look like (int, int, str) -> float. A matc
On Thu, Sep 30, 2021 at 4:19 PM Steven D'Aprano wrote:
>
> On Wed, Sep 29, 2021 at 02:09:03PM -0700, Guido van Rossum wrote:
> > Over in typing-sig we're considering a new syntax for callable *types*,
> > which would look like (int, int, str) -> float. A matching syntax for
> > lambda would use a
On Wed, Sep 29, 2021 at 02:09:03PM -0700, Guido van Rossum wrote:
> Over in typing-sig we're considering a new syntax for callable *types*,
> which would look like (int, int, str) -> float. A matching syntax for
> lambda would use a different arrow, e.g. (x, y, z) => x+y+z.
I like arrow operators
Over in typing-sig we're considering a new syntax for callable *types*,
which would look like (int, int, str) -> float. A matching syntax for
lambda would use a different arrow, e.g. (x, y, z) => x+y+z.
On Wed, Sep 29, 2021 at 11:51 AM Stephen J. Turnbull <
stephenjturnb...@gmail.com> wrote:
> Do
Chris Angelico wrote:
> On Wed, Sep 29, 2021 at 10:56 PM Dominik Vilsmeier
> dominik.vilsme...@gmx.de wrote:
> > members.sort(key=(?[1], ?[0]))
> > How do you know whether this is one function that returns a tuple, or
> a tuple of two functions?
> ChrisA
You are right, I didn't think of this ambig
On 2021-09-29 10:11, Dominik Vilsmeier wrote:
Lambda functions that have a single parameter are a common thing, e.g. for "key" functions:
`sorted(items, key=lambda x: x['key'])`. For these cases however, the rather long word
"lambda" together with the repetition of the parameter name, results i
Given that we have comprehensions that use s simple expression, and
operator.itemgetter for common keys, the use cases for these simple lambdas
are pretty rare these days.
Sure, some folks seem to prefer map and filter as a matter of style, but I
don’t think we need to create cryptic notation to m
On Wed, Sep 29, 2021 at 09:11:35AM -, Dominik Vilsmeier wrote:
> * `sorted(items, key=?['key'])`
> * `filter(? > 0, items)`
> * `map(f'{?:.3f}', items)`
I think those are massively more cryptic and hard to read than an
explicit lambda. Being too terse is worse that being too verbose:
consid
IIUC a lot of what is being discussed has been implemented by the "placeholder"
package on PyPI
Here: https://pypi.org/project/placeholder/
It allows using things like `min(data, key=_[-1])` or `_.age < 18` (just using
language features instead of adding new syntax).
___
I find this approach too cryptic compared to reading regular Python
notation, my brain has to mode switch to make sense of it. Would a little
extra ?: be too much add to make clear it's a lambda function, e.g.
?: ? > 0 instead of ? > 0
Also either approach *could *add multi-argument lambdas:
?1, ?
Will we be able to splat/unpack the `?`?
>>> args = get_starting_list_values()
>>> args
(1, 2, 3)
>>> dd = defaultdict([*?])
>>> dd["spam"]
[1, 2, 3]
or:
>>> kwargs = get_kwargs()
>>> kwargs
{'x': 1, 'y' 2, 'z': 3}
>>> dd = defaultdict(Node(**?))
>>> dd["eggs"]
Node(x=1, y=2, z=3)
---
Ricky.
"
On Wed, Sep 29, 2021 at 10:56 PM Dominik Vilsmeier
wrote:
> members.sort(key=(?[1], ?[0]))
How do you know whether this is one function that returns a tuple, or
a tuple of two functions?
ChrisA
___
Python-ideas mailing list -- python-ideas@python.org
T
22 matches
Mail list logo