Trying to understand nested loops

avi.e.gross at gmail.com avi.e.gross at gmail.com
Fri Aug 5 20:28:31 EDT 2022


I had considered that, Dave. Albeit others did at least put in some
three-dot markers to show there was other code between the three lines
shown.

But the same silly argument they used applies elsewhere. Consider nested
calls like:

Delta(Gamma(Beta(Alpha)))

Now say one of those functions takes an argument like 666.

The following lines all mean different things, especially if all the above
functions can take an optional argument of 666.

Delta(Gamma(Beta(Alpha,666)))
Delta(Gamma(Beta(Alpha),666))
Delta(Gamma(Beta(Alpha)),666)
Delta(666,Gamma(Beta(Alpha)))
Delta(Gamma(666,Beta(Alpha)))
Delta(Gamma(Beta(666,Alpha)))

And of course any such function calls may be in contexts such as this:

Result, const = Delta(Gamma(Beta(Alpha))),666

My point is that whether using indentation or parentheses or braces or other
grouping techniques, exact placement according to the rules must apply. I
often write code where I use indentation to remind ME which argument goes
with which, such as this (more often not in python where indentation has no
real meaning and things can span multiple lines.

This:

Delta(Gamma(666,Beta(Alpha)))

May make more sense to write like this:

Delta(Gamma(666,
            Beta(Alpha)))

Or in a more general case where each of the functions may take multiple
arguments before and/or after nested, calls, I might have a long convoluted
code where all arguments to a particular function are vertically aligned and
it is easier to spot if you left one out or put it in the wrong place.

It becomes a somewhat childish argument when writing CODE in any language
with rules, to suggest that it should ignore your mistakes and assume you
meant to have a comma here or parentheses there and similarly, that the
indentation level should govern which block your print statement is part of.


Hence my suggestion that perhaps someone is in a sense punking us

Of course it is perfectly possible the software this person is using makes
that deliberately unworkable email address as I have seen this elsewhere. It
just raises my suspicion level when I have seen other posts on various
mailing lists ranging from someone with pretty much no knowledge about a
topic but wanting someone to do their homework, to someone who throws in
something (perhaps incendiary) to watch others waste their time trying to
deal with their best guesses of what was wanted, to one guy who seems to
write articles or books and wants to see what people think but then does not
participate or tell us that is what they wanted.

My point was not to tell anyone else here what to do, simply that I will be
cautious with such posters as I have way better things to do!

Nested loops are indeed a hard topic for many. But when explained it no
longer seems reasonable to ask why print statements at different levels of
nesting differ.

Not to me, at least.

- Avi (for those like someone on another language/group who did not know how
to address me in overall too-polite format and referred to me as "Dear
" followed by more lines.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com at python.org> On
Behalf Of dn
Sent: Friday, August 5, 2022 7:58 PM
To: python-list at python.org
Subject: Re: Trying to understand nested loops

On 06/08/2022 11.41, avi.e.gross at gmail.com wrote:
> I wonder if someone is pulling our leg as they are sending from an 
> invalid email address of "GB <NOTsomeone at microsoft.invalid>" which is a
bit sick.

There are a number of folk who use evidently false email addresses - the
OP's had me amused.

Such 'hiding' is a matter for the List-Admins (thanks for all the work
exerted on our behalf!) and how it fits with the Code-of-Conduct.


> I have trouble imagining ANYONE learning a language like python 
> without rapidly being told that python uses indentation instead of 
> various ways to detect when a body of text is considered a single
composite item.
> 
> And code like their example is also nonsense:
> 
> print(var)
>      print(var)
>          print(var)

Another way to look at that post, and what the author may have meant; is
that the final print(), incorrectly indented in the OP, could have been
written with three different indentations, and thus have three very
different effects (cf that they are all to be used, as-is).
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list