Here is a trivial program (I am using Python 3.13.3 on Windows 11):
def main():
def sub():
nonlocal line
print(len(line))
line += 'x'
res.append('y')
line = ''
res = []
sub()
print(line, res)
main()
The output, as expected, is
0
x ['y']
What
On Thu, 17 Sept 2026 at 20:44, Rob Cliffe via Python-list
wrote:
>
> Here is a trivial program (I am using Python 3.13.3 on Windows 11):
>
> def main():
> def sub():
> nonlocal line
> print(len(line))
> line += 'x'
> res.append('y')
> line = ''
>
Rob,
Two different operations are happening, and only one of them writes to a name.
nonlocal and global control where an assignment to a name goes. They have
nothing to do with mutating objects.
- line += 'x' is an assignment. It rebinds the name line to a new string. Since
sub assigns to
Two checkable receipts for the cons column, run on stock CPython 3.11.6 (extras
policy is driver-specific; this is the stdlib sqlite3):
1. On "all local variables are exposed": the driver does not push back. With
named placeholders, extra keys are silently ignored and only missing ones raise
Hello Python Community,
I'm Amine, maintainer of Ptero Pro AI Chat, a free, non-profit, open-source
AI chat platform (GPL v2).
I wanted to share that Ptero now offers DeepSeek V4.1 Flash for free — no
sign-up, no paywall, no credit card. It's particularly useful for Python
developers who want