> On 27 May 2021, at 09:56, Shreyan Avigyan <pythonshreya...@gmail.com> wrote:
> 
> Lot of programming languages have something known as static variable storage 
> in *functions* not *classes*. Static variable storage means a variable 
> limited to a function yet the data it points to persists until the end of the 
> program. Well Python also kind of has that functionality. Python's default 
> values provide the same type of functionality but it's a *hack* and also 
> *problematic* because only mutable types that are mutated persists. Static 
> should behave much like Python's for loop variables. This idea proposes to 
> add a keyword (static, maybe?) that can create static variables that can 
> persist throughout the program yet only accessible through the function they 
> are declared and initialized in.

How experienced are your with Python? On first glance your recent proposals 
appear to be for feature in languages you know about and can’t find in Python, 
without necessarily a good understanding of Python.

For this particular question/proposal:  “static” variables in functions in C 
like languages are basically hidden global variables, and global variables are 
generally a bad idea.  In Python you can get the same result with a global 
variable and the use of the “global” keyword in a function (or cooperating set 
of functions) when you want to update the global variable from that function.  
Closures or instances of classes with an ``__call__`` method can be used as 
well and can hide state (with the “consulting adults” caveat, the state is 
hidden, not inaccessible).

Ronald

—

Twitter / micro.blog: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JLCCATPIOY3SKF4PYVMLEPYJH4WZZ5XJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to