Use of a variable in parent loop

Avi Gross avigross at verizon.net
Sun Sep 27 16:17:34 EDT 2020


These discussions can be  bit frustrating. People talk past each other.
Languages seem almost like religions, as do paradigms.

I try to stay above it and absorb each paradigm  as an alternative choice
made and then try to think of what problems I can solve better with one or
another and so on.

 Programming languages are often created when people have new ideas and want
to try them out, often keeping a good chunk of the language similar enough
to other languages so they seem partially familiar and then diverge.

Whether a particular text editor has a mode than honors your typing in a
language is  a side issue. Whether you can use cut and paste properly is a
similar side issue. Python chose indentation so you can remove lots of curly
braces and often semi-colons that clutter other languages. There is a
trade-off. In general, you can use superfluous symbols harmlessly such as
curly braces above and below a region so that it looks like a BLOCK but that
won't make it a block for purposes that language does not consider a good
feature.

And another trade-off is that it is not really a compiled language and
variables are looked up dynamically in a varying path of namespaces and the
same name can constantly change what kinds of objects it holds. There is
lots of freedom there that I appreciate as compared to some C-inspired
languages including GO that I am learning now, just for fun. I do lots of
prototyping and that is easier to do when less constrained but a final
program may well run better in a compiled form.

But like human languages, some people may not easily be able to switch to a
new one that violates what to them seem obvious rules. I was exposed to many
in childhood so some sounds are easy for me to hear and pronounce that
others cannot deal with but I am apparently tone deaf when I try to learn a
language like Mandarin that uses some kind of "tones" and certainly am not
willing to learn an alphabet that is not sound-based and has tens of
thousands of characters. But, I seem able to handle many alphabets that exit
in European and Semitic languages even when they use the same apparent
letters in very different ways. To each their own.

So for those replying here that the person asking a question needs to drop
their preconceptions and instead learn what Python IS DOING, I fully agree
as long as it is done gently. But when someone insists Python needs to
change to meet their preconception, I get less sympathetic. A language that
has been around for decades is often hard to change without breaking things
and we know Python 2.X and earlier are not particularly compatible and what
trouble that has caused. Other languages like PERL have had such schisms and
growing pains. Sometimes a better solution is to start a new language from
scratch and just keep what you want and freely add new.

Dumb example, perhaps, is  features I see in GO. Some are quite interesting
but I am not demanding they be added to Python or R or any other language I
use. Heck, some may mess up existing programs. Go has a "defer" statement
that creates a stack of function calls to be done AFTER the function
creating them returns. While that can be nifty, it is a very different
paradigm. But a different paradigm in say R allows you to specify what must
be done on exit from a function even if it exist badly. Python has variants
as well including for some protocols that close open files if used  in a
"with" and so on. Lots of ideas out there but you have to use what your
language comes with to a point, or work out your own variants of objects or
add wrappers around functions and so on. Python has tons of such techniques
if you read the documentation and other literature.

And, yes, there are text editors designed better to handle writing code in
python and also external utilities you can use to reformat the code in many
cases to your needs.

I have found that in programming IDEAS, there are many forks in the road as
design decisions you make and amazingly often you can find one or more
programming environments where one or another fork has been taken. There
often is no one right answer that everyone agrees with and choices are often
made for other reasons such as how easy the creators can implement things
even if the result is harder to program some things in.

Avi

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of 2QdxY4RzWzUUiLuE at potatochowder.com
Sent: Sunday, September 27, 2020 8:17 AM
To: python-list at python.org
Subject: Re: Use of a variable in parent loop

On 2020-09-27 at 15:18:44 +0800,
Stephane Tougard via Python-list <python-list at python.org> wrote:

> In many non declarative language, if I do print($var), it just prints 
> and undefined value with returning an error.

If I want "many non declarative language[s]," I know where to find them, and
I won't expect them to honor Python's semantics.  In Python, a name doesn't
have a value unless and until you bind it to one.

There's a lot more to learning a new language than the syntax.
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list