Where I do ask for a new feature

avi.e.gross at gmail.com avi.e.gross at gmail.com
Fri Oct 20 13:48:41 EDT 2023


I still see no great reason for a new feature here and the namespace issue has often been discussed. You can always opt to create your own namespace of some sort and make many of your variables within it and always refer to the variables explicitly so the only collisions that can happen are your own carelessness.

I do note that reusing a variable like "i" is not uncommon and especially when it is merely used as a looping variable. Generally anything else using the same variable does not need to refer to the other use and is in another scope.

May I politely ask if you can point to other languages that have the feature you want and what it looks like. How does it know when the variable can safely go away? Does it allow you to create your alias in something like a loop and re-assign it or is it more like a constant once set and so on?

If you have a good use case with no other easy way to provide it, you still need to show it is more important than oodles of other feature requests before anyone would consider seriously doing it in some future release.

I am wondering if your concept of an alias is more typographical than actual. I mean in languages like C, there was often a preprocessor that went through your code and made changes like:

#DEFINE filename "/usr/me/dir/subdir/file.c"

This could allow some shorter typing but would not have anything in the namespace on the compiler level which would just see the longer substitutions. 

Could Python include something like this by keeping a table of symbols and replacements or running a pre-processor first? Maybe. But as stated, it does not seem to be a NEED that some feel is important. Assigning a variable to hold a pointer of sorts does indeed add to the namespace but the resource involved is not a big deal. Python is an interpreted language that makes one pass but there are languages that make multiple passes through the code and allow things like defining a function after it has been called. That is not pythonic.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com at python.org> On Behalf Of Roel Schroeven via Python-list
Sent: Friday, October 20, 2023 3:55 AM
To: python-list at python.org
Subject: Re: Where I do ask for a new feature

Op 20/10/2023 om 5:16 schreef Bongo Ferno via Python-list:
> On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, avi.e... at gmail.com wrote:
>
> > There are many ways to make transient variables that disappear at some time 
> > and do we need yet another? Yes, you can create one of those ways but what 
> > is the big deal with deleting a variable when no longer used? 
>
> Assigning a variable to something can be anything else than a temporal alias.
> A with statement makes clear that the alias is an alias and is local, and it automatically clears the variable after the block code is used.
>
> Python clutters the variable space with vars that are needed only on certain places, and an alias doesn't has a scope.
> Convenient alias are short names, and short names are limited in quantity. If the space is cluttered with short alias, it opens risks for wrong utilization.
>
> Its like writing a "for i" in a list comprehension and having to worry if "i" was already used in another place..
As long as functions are kept reasonably short, which is a good idea 
anyway, I don't really see any of that as a problem.

-- 
"Experience is that marvelous thing that enables you to recognize a
mistake when you make it again."
         -- Franklin P. Jones

-- 
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list