[New-bugs-announce] [issue7485] Error in FAQ entry '4.25 Why doesn't Python have a "with" statement for attribute assignments?'
report at bugs.python.org
Sat Dec 12 13:16:37 CET 2009
New submission from Eric Smith <eric at trueblade.com>:
The documentation says: "If the referenced object does not have a, b and
c attributes, of course, the end result is still a run-time exception."
For the given example, this is likely not true. Since the attributes are
being assigned to, they will be created. The example is equivalent to:
>>> class a(object): pass
>>> ref = a()
>>> ref.a = 21
>>> ref.b = 42
>>> ref.c = 63
nosy: eric.smith, georg.brandl
title: Error in FAQ entry '4.25 Why doesn't Python have a "with" statement for attribute assignments?'
versions: Python 2.6
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce