Welcome to this forum. A general remark: It would be good to start with a concise presentation of an ideas here. I do not consider it too helpful to blow everything up to a document entitled “pre-PEP” that somehow mimics the structure of a PEP, without actually meeting the quality criteria for a PEP.
While the idea itself has some merits, your proposal is rather unclear and actually self contradictory.
While from the prosa, it is rather (not completely however) clear what you mean with local scoping of variables, this idea does not fit with your code examples, like when you write:
for i::, j:: int, k: int in iterable:
BODY
behaves like
try:
def __pep_block__():
for __tmp in iterable:
i, j, k = __tmp
BODY
__pep_block__()
finally:
for __name in ['i', 'j']:
try:
del globals()[__name]
except KeyError:
pass
This does not at all what you describe:
k would be local here (although it does not use the :: marker you have designated as markers for locally scoped variables).
i and j are not only locally scoped, but additionally deleted from the globals. That does not make sense either.
So the explanation of the code should be acutally like:
def __pep_block():
nonlocal k
for i,j,k in iterable:
BODY
__pep_block()
or possibly like:
for __name in ['i', 'j']:
__saved[__name] = globals()[__name]
try:
for i,j,k in iterable:
BODY
finally:
for __name in ['i', 'j']:
globals()[__name] = __saved[__name]
del __saved
Another alternative would be
for __private_i,__private_j,k in iterable:
BODY # In the whole body i and j are replaced
# by __private_i or __private_j, respectively.
del __private_i
del __private_j
In all three cases the private names starting with two underscores would be private names that cannot clash with any existing names. All three options would have slightly different semantics that a true PEP would need to address.