Sujet : Re: Where I do ask for a new feature
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 20. Oct 2023, 12:58:26
Autres entêtes
Organisation : Stefan Ram
Message-ID : <definition-20231020125741@ram.dialup.fu-berlin.de>
References : 1 2 3 4 5 6 7 8
Bongo Ferno <
bongoferno@gmail.com> writes:
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 does not seem to have blocks in the way of C and
many other languages.
One could use a "del" to clarify the scope:
tmp = x
x = y
y = tmp
del tmp
. But I believe that the mainstream sees this as bad style.
What comes most close to a block in Python, is a function definition:
def f( ... ):
tmp = ...
. This expresses that the scope of "tmp" is that function definition.