On Tue, 1 Mar 2022 at 17:31, Svein Seldal wrote:
> for x in (a for a in y if c):
-1 on this form, I know it's supported, but I can see it getting ugly, i.e.
for x in (a for x in (a for x in a)) # add a few more "for x in (a"
and it will get messy fast
> or
>
> it = (a for a in
+1
Python has always seemed to me to allow one to completely describe exactly what
you are iterating over in a for loop in the one line containing the for
statement. And that is more or less the principle I tend to follow, unless the
for statement simply gets to be too long. I have even used
As someone who has read the entirety of those thread and is not a core-dev
but having some experience with breaking and non-breaking changes at scale,
from my perspective:
1. This is a common syntax for an existing idea that is intuitive given
other existing syntax (comprehensions)
2. This would
On 8/03/22 12:32 pm, Chris Angelico wrote:
All I can see is that
changes get proposed on typing-sig and actually make it into the
language, but changes that get proposed on python-ideas are invariably
shot down in flames,
Typing is an area of Python that is under active development, so
it is
On Mon, 7 Mar 2022 at 23:44, Chris Angelico wrote:
> Not ALL typing changes are just new things in typing.py, so that
> doesn't cover everything. And yes, I am sure that a lot of things get
> proposed and not implemented - my point is that typing-sig is
> successfully finding the good ideas and
On 2022-03-07 21:32, Stephen J. Turnbull wrote:
Brendan Barnwell writes:
> I would be happier if fewer typing-related changes made it in.
I'm curious: do you use type annotations yourself? If yes, do you
just prefer minimal hints to a precise typing system, or have there
been changes that
On Tue, 8 Mar 2022 at 15:37, Brendan Barnwell wrote:
>
> On 2022-03-07 15:32, Chris Angelico wrote:
> > On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote:
> >>
> >> On 2022-03-06 14:43, Chris Angelico wrote:
> >> > This keeps happening. All the successful ideas seem to happen
> >> > elsewhere,
Brendan Barnwell writes:
> I would be happier if fewer typing-related changes made it in.
I'm curious: do you use type annotations yourself? If yes, do you
just prefer minimal hints to a precise typing system, or have there
been changes that are actually harmful in your opinion?
As someone else noted, few of the ideas originating on typing-sig are for
syntax changes.
One might argue that some are "abuse of notation." Generally they are of
the sort "let's support indexing or bitwise operators on some more types"
or let's let more builtin things act as types in
On Mon, Mar 7, 2022, 9:12 PM Jelle Zijlstra
wrote:
>
>
> El lun, 7 mar 2022 a las 19:57, Christopher Barker ()
> escribió:
>
>> On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote:
>>
>>> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra
>>> wrote:
>>> >
>>> >
>>> >
>>> > El lun, 7 mar 2022 a las
On 2022-03-07 15:32, Chris Angelico wrote:
On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote:
On 2022-03-06 14:43, Chris Angelico wrote:
> This keeps happening. All the successful ideas seem to happen
> elsewhere, notably on typing-sig.
You seem to see that as a positive thing, but
On Tue, 8 Mar 2022 at 15:10, Jelle Zijlstra wrote:
>
>
>
> El lun, 7 mar 2022 a las 19:57, Christopher Barker ()
> escribió:
>>
>> On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote:
>>>
>>> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra
>>> wrote:
>>> >
>>> >
>>> >
>>> > El lun, 7 mar 2022 a
El lun, 7 mar 2022 a las 19:57, Christopher Barker ()
escribió:
> On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote:
>
>> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra
>> wrote:
>> >
>> >
>> >
>> > El lun, 7 mar 2022 a las 15:35, Chris Angelico ()
>> escribió:
>> >but python-ideas is 100%
On Mon, Mar 7, 2022 at 3:43 PM Chris Angelico wrote:
> On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra
> wrote:
> >
> >
> >
> > El lun, 7 mar 2022 a las 15:35, Chris Angelico ()
> escribió:
> >but python-ideas is 100% shooting ideas to pieces.
100% really? Maybe my sense of time is blurred, but
On Tue, 8 Mar 2022 at 10:39, Jelle Zijlstra wrote:
>
>
>
> El lun, 7 mar 2022 a las 15:35, Chris Angelico () escribió:
>>
>> On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote:
>> >
>> > On 2022-03-06 14:43, Chris Angelico wrote:
>> > > This keeps happening. All the successful ideas seem to
El lun, 7 mar 2022 a las 15:35, Chris Angelico ()
escribió:
> On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell
> wrote:
> >
> > On 2022-03-06 14:43, Chris Angelico wrote:
> > > This keeps happening. All the successful ideas seem to happen
> > > elsewhere, notably on typing-sig.
> >
> > You
On Tue, 8 Mar 2022 at 10:20, Brendan Barnwell wrote:
>
> On 2022-03-06 14:43, Chris Angelico wrote:
> > This keeps happening. All the successful ideas seem to happen
> > elsewhere, notably on typing-sig.
>
> You seem to see that as a positive thing, but I would be happier if
> fewer
On 2022-03-06 14:43, Chris Angelico wrote:
This keeps happening. All the successful ideas seem to happen
elsewhere, notably on typing-sig.
You seem to see that as a positive thing, but I would be happier if
fewer typing-related changes made it in.
--
Brendan Barnwell
"Do not follow where
Chris Angelico writes:
> It's good to have a bit of inertia, so that status quo gets
> maintained, but at the moment, the extent to which ideas get shot
> down makes it look as if this list is python-idea-killing. This
> keeps happening.
I don't see lots of *good* ideas for syntax changes
On Sun, 6 Mar 2022 at 22:43, Chris Angelico wrote:
>
> On Mon, 7 Mar 2022 at 09:33, Paul Moore wrote:
> > > Do I care enough to write a PEP? No. So this, like many other small
> > > ideas, will probably die on the vine.
> >
> > Yes, this is the real problem. It's simply not compelling enough,
>
> Earlier on the thread, I made a similar point that it would be nice to
> have a way to filter without the redundant for x in x. Though I can’t think
> of a really good way to express it. But as for filtered for loops:
>
> "for thing in
> (x for x in collection if is_interesting(x))"
>
It's
On Mon, 7 Mar 2022 at 09:33, Paul Moore wrote:
> > Do I care enough to write a PEP? No. So this, like many other small ideas,
> > will probably die on the vine.
>
> Yes, this is the real problem. It's simply not compelling enough, even
> for supporters of the idea, for them to do the necessary
On Sun, 6 Mar 2022 at 21:41, Christopher Barker wrote:
>
>
>> Personally, I'm certainly not ignoring comprehensions. "for thing in
>> (x for x in collection if is_interesting(x))" uses comprehensions just
>> fine, if you don't like the verbosity of "x for x in", then that's an
>> issue with
> Personally, I'm certainly not ignoring comprehensions. "for thing in
> (x for x in collection if is_interesting(x))" uses comprehensions just
> fine, if you don't like the verbosity of "x for x in", then that's an
> issue with comprehensions, not a reason why comprehensions don't
> address this
On Sun, 6 Mar 2022 at 01:55, Christopher Barker wrote:
>
> On Sat, Mar 5, 2022 at 4:33 AM Paul Moore wrote:
>>
>> for thing in filter(is_interesting, this_collection):
>> ...
>>
>> That seems pretty non-clunky. Is the issue here that "filter" is not
>> sufficiently well-known? Or that you
On Sat, Mar 5, 2022 at 4:33 AM Paul Moore wrote:
> for thing in filter(is_interesting, this_collection):
> ...
>
> That seems pretty non-clunky. Is the issue here that "filter" is not
> sufficiently well-known? Or that you don't want to name the
> is_interesting function, and lambdas are
On Sat, 5 Mar 2022 at 12:43, Chris Angelico wrote:
>
> The throwaway function is a *terrible* idea for a lot of situations,
> because it puts the condition completely out-of-line. You have to go
> dig elsewhere to find out the meaning of the filter. A lambda function
> can work, but is about as
Chris Angelico writes:
> What Python needs is a non-clunky way to express [filtered iteration].
I don't. In my own code there aren't any else-less cases of for: if:.
All the filtered iterations have intervening code at the top of the
loop before the if. Most could be refactored to use
On Sat, 5 Mar 2022 at 23:32, Paul Moore wrote:
>
> On Sat, 5 Mar 2022 at 12:12, Chris Angelico wrote:
> >
> > On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull
> > wrote:
> >
> > > Python has one, and you've already mentioned it:
> > >
> > > for thing in (x for x in this_collection if
On Sat, 5 Mar 2022 at 12:12, Chris Angelico wrote:
>
> On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull
> wrote:
>
> > Python has one, and you've already mentioned it:
> >
> > for thing in (x for x in this_collection if is_interesting(x)):
> >
> > It's noticably verbose, but it's an exact
On Sat, 5 Mar 2022 at 22:22, Stephen J. Turnbull
wrote:
>
> Chris Angelico writes:
>
> > What Python needs is not a way to cram more onto one line. What Python
> > needs is a way to express an abstract concept: "iterate over the
> > interesting parts of this collection".
>
> Python has one,
Chris Angelico writes:
> What Python needs is not a way to cram more onto one line. What Python
> needs is a way to express an abstract concept: "iterate over the
> interesting parts of this collection".
Python has one, and you've already mentioned it:
for thing in (x for x in
On Sat, 5 Mar 2022 at 04:34, Christopher Barker wrote:
>
>
>> > In the status quo, we have a filtered loop written as:
>> >
>> > for item in items:
>> > if condition:
>> > block
>
>
> The thing is, if block is more than a couple lines, you need to look down to
> see if
> > In the status quo, we have a filtered loop written as:
> >
> > for item in items:
> > if condition:
> > block
The thing is, if block is more than a couple lines, you need to look down
to see if there’s an else or any number of elif blocks down there— so this
isn’t a
This post is rather off topic. If you don't want to get bogged down in
philosophical arguments, you might want to skip this one and come back
to my next reply, which I promise will be more on top.
On Fri, Mar 04, 2022 at 04:39:12AM +1100, Chris Angelico wrote:
> > They also do a better job of
On Fri, 4 Mar 2022 at 02:48, Steven D'Aprano wrote:
>
> On Thu, Mar 03, 2022 at 10:30:32PM +1100, Chris Angelico wrote:
> > On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote:
> > > What did I say that made you think I denied the existence of filtered
> > > iteration? Was it the post where I
On Thu, Mar 03, 2022 at 10:30:32PM +1100, Chris Angelico wrote:
> On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote:
> > What did I say that made you think I denied the existence of filtered
> > iteration? Was it the post where I pointed out we've been able to do
> > filtered iteration going
What I said:
"Python, for good or ill, is an opinionated language regarding
indentation and statements."
And then Greg refuted something I never said:
> So if Python is opinionated about line lengths, it's rather
> selectively opinionated.
The Python language isn't opinionated about line
On Thu, 3 Mar 2022 at 21:14, Steven D'Aprano wrote:
> What did I say that made you think I denied the existence of filtered
> iteration? Was it the post where I pointed out we've been able to do
> filtered iteration going back to Python 1.x days?
ANYTHING can be done by composing concepts. We
On 3/03/22 9:50 pm, Steven D'Aprano wrote:
While you can put the block on the same line as the colon using
semicolons:
if condition: print(1); print(2) # Legal.
and there's nothing to stop you from making arbitrarily long
lines using this feature...
if condition: print(1);
On Thu, Mar 03, 2022 at 08:04:57PM +1100, Chris Angelico wrote:
> Python has a history of making conceptual actions shorter than the
> mere combination of their parts. For instance, we don't have this
> construct:
>
> for i in range(len(stuff)) using thing = stuff[i]:
Rather than inventing new
On Thu, 3 Mar 2022 at 19:54, Steven D'Aprano wrote:
>
> On Thu, Mar 03, 2022 at 02:32:25AM +, Rob Cliffe via Python-ideas wrote:
>
> > But the proposal would give people the choice of
> > Saving a level of indentation at the cost of having two
> > suite-introductions on the same line.
> >
On Thu, Mar 03, 2022 at 02:32:25AM +, Rob Cliffe via Python-ideas wrote:
> But the proposal would give people the choice of
> Saving a level of indentation at the cost of having two
> suite-introductions on the same line.
> Keeping the two suit-introductions on separate lines (as
On 02/03/2022 20:03, David Mertz, Ph.D. wrote:
I really am shocked by how many people seem to have broken ENTER keys
on their keyboards.
You mock. (As far as I remember you have always opposed new language
features/changes. Correct me if I am wrong.)
But the proposal would give people the
On 02/03/2022 20:03, David Mertz, Ph.D. wrote:
I really am shocked by how many people seem to have broken ENTER keys
on their keyboards.
You mock. (As far as I remember you are always opposed to new language
features/changes.)
But the proposal would give people the choice of
Saving a
I have had precisely the same idea.
It feels better to make this feature general (if introduced at all) than
make it specific to 'for' + 'if'.
I think there would have to be a rule that any 'if' that appeared on a
line with other suite-introducing-statements could not have a
corresponding
On Wed, Mar 02, 2022 at 09:25:01AM -0500, Ricky Teachey wrote:
> Is there some opportunity for some kind of compiler magic when the iterable
> of a for loop is fully contained in a place easily findable by the
> compiler, and not spread over multiple if and for statements?
I am not an expert on
I really am shocked by how many people seem to have broken ENTER keys on
their keyboards.
Let's just keep Python readable rather than see how much we can cram on a
line.
On Wed, Mar 2, 2022, 2:56 PM Jeremiah Paige wrote:
> I have on a few occasions wanted a for..in..if statement and if it
I have on a few occasions wanted a for..in..if statement and if it existed
would
have used it. However, I agree that the level of change a new statement type
brings to the language is probably too high for this feature.
But what if python lifted the newline requirement for blocks that contain
On Thu, 3 Mar 2022 at 01:28, Ricky Teachey wrote:
>
> I think I'm -0.5 but I have a question for the people on here smarter than me
> (pretty much all):
>
> Is there some opportunity for some kind of compiler magic when the iterable
> of a for loop is fully contained in a place easily findable
On Wed, Mar 2, 2022 at 2:25 AM Steven D'Aprano wrote:
> > I think it's really the equivalent of
> >
> > for x in y:
> > if not x in c:
> > break
> > do_stuff
> >
> > which to me give the proposed syntax a bit more relative strength.
>
> Forgotten the difference between continue
I think I'm -0.5 but I have a question for the people on here smarter than
me (pretty much all):
Is there some opportunity for some kind of compiler magic when the iterable
of a for loop is fully contained in a place easily findable by the
compiler, and not spread over multiple if and for
I've heard "evaluation map" for a related mathematical concept: the natural map
from X to (X -> Y) -> Y in some cartesian closed category (whatever that means
:-), like the natural embedding of a vector space into its double dual space,
or like this sort of eval_at function that you can then
On Wed, 2 Mar 2022 at 10:27, Steven D'Aprano wrote:
> Off-topic, but since you raised the issue... is there a standard
> functional programming term for a variant of map() that applies a single
> argument to a series of different functions?
>
> # regular map
> map(func, list_of_args) #
On Tue, Mar 01, 2022 at 09:27:05PM -0800, Christopher Barker wrote:
> I think it's really the equivalent of
>
> for x in y:
> if not x in c:
> break
> do_stuff
>
> which to me give the proposed syntax a bit more relative strength.
Forgotten the difference between continue and
On Wed, Mar 02, 2022 at 05:01:38PM +0900, Stephen J. Turnbull wrote:
> My 63-year-old eyes struggle with 80-character lines, but in all
> fairness to those with better eyesight I'm not going to argue for
> Mom's 65[1].
This is a very good point that the "80 columns is too short" crowd
forget.
Michael Smith writes:
> This is just a small improvement, but worthwhile. It's intuitive IMO to be
> able to use similar filtering expressions to comprehensions at the top of a
> for loop.
Intuitive I guess, but in comprehensions it was "strictly from need"
since comprehension syntax is an
Steven D'Aprano writes:
> On Wed, Mar 02, 2022 at 02:28:33AM +0100, Svein Seldal wrote:
>
> > for x in y if x in c:
> > some_op(x)
>
> What does this new syntax give us that we don't already have with this?
>
> for x in y
> if x in c:
> some_op(x)
On Tue, Mar 01, 2022 at 10:40:06PM -0500, Michael Smith wrote:
> +1
>
> This is just a small improvement, but worthwhile. It's intuitive IMO to be
> able to use similar filtering expressions to comprehensions at the top of a
> for loop.
Good news! We have been able to use filtering conditions
On Tue, Mar 1, 2022 at 6:43 PM Steven D'Aprano wrote:
> > for x in y if x in c:
> > some_op(x)
>
> What does this new syntax give us that we don't already have with this?
>
> for x in y
> if x in c:
> some_op(x)
>
I think it's really the equivalent of
for x
+1
This is just a small improvement, but worthwhile. It's intuitive IMO to be
able to use similar filtering expressions to comprehensions at the top of a
for loop.
Here's an example:
# get the Hadoop version by scanning pyspark jars.
# Vague attribution:
https://stackoverflow.com/a/50242383
for
-1. Extra complexity for no benefit. Attractive nuisance to making overly
complex statement lines.
On Tue, Mar 1, 2022, 8:31 PM Svein Seldal wrote:
> I'm sorry for reposting, but this message got stuck in moderation
> approval for 5 days so I figured I should try again.
>
>
> I'd like to
1. It aligns with existing syntax in list comprehensions and generator
expressions.
2. In probably majority of cases it would be more readable to me;
"iterate over iterable for items meeting condition:".
3. Could it be easier to optimize an explicit filter expression to
improve iteration
On Wed, Mar 02, 2022 at 02:28:33AM +0100, Svein Seldal wrote:
> for x in y if x in c:
> some_op(x)
What does this new syntax give us that we don't already have with this?
for x in y
if x in c:
some_op(x)
or the other multiple ways of writing the equivalent
Very strong +1.
On Wed, 2022-03-02 at 02:28 +0100, Svein Seldal wrote:
> I'm sorry for reposting, but this message got stuck in moderation
> approval for 5 days so I figured I should try again.
>
>
> I'd like to propose extending the for statement to include
> conditionals
> akin to
65 matches
Mail list logo