Since we are talking about namedtuple and implementation, I just noticed:

In [22]: Point = namedtuple('Point', ['x', 'y'])
In [23]: p = Point(2,3)

In [24]: p.x = 5
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-24-328d3fab3e30> in <module>()
----> 1 p.x = 5
AttributeError: can't set attribute

OK -- that makes sense. but then, if you try:

In [25]: p.z = 5
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-25-625ed954d865> in <module>()
----> 1 p.z = 5
AttributeError: 'Point' object has no attribute 'z'

I think this should be a different message -- key here is that you can't
set a new attribute, not that one doesn't exist. Maybe:

"AttributeError: can't set new attribute"

-CHB

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to