<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 3, 2011, at 7:14 PM, Greg Ewing wrote:</div><blockquote type="cite"><div><br><blockquote type="cite">I don't think that assignment decorators add a significant new capability.  AFAICT, it just saves a few characters but doesn't change the way we think or work.<br></blockquote><br>As I've tried to point out, it's about more than just saving<br>characters. It's about allowing the programmer to follow DRY,<br>which is an important software engineering issue. It's also<br>about improving readability, because that counts, you know.\<br></div></blockquote><br></div><div>We both agree about the virtues of readability and DRY. I just disagree that either applies in the case of named tuples.</div><div><br></div><div>The following seems weird to me and causes a mental hiccup when reading it:</div><div><br></div><div>  @namedtuple</div><div>  Point = 'x y'       </div><br><div>The existing, Point = namedtuple('Point', 'x y') says what it does and my eyes just breeze over it.  So, I don't see a readability win.</div><div><br></div><div>Also, I don't think the DRY principle applies.  That is all about factoring-out a piece of knowledge so that it is used only once.  However, the use for named tuples is to define the class and then use that class name many times.  So, you still end-up using the name over and over again.  It is deeply embedded in the program.  You can't factor-out all of them with the proposed syntax, so you don't get any of the purported benefits of DRY:</div><div>   '''<span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; ">When the DRY principle is applied successfully, a modification of any </span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; ">   single element of a system does not change other logically-unrelated elements'''</span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; ">To change the name of the class, you still have to do a global substitution, hitting the definition, every invocation, and its appearance in docs.  IOW, the class name is not a piece of knowledge that can be abstracted away.</span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><br></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; ">Another software engineering principle, t</span><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; ">he "Rule of Three" suggests that the proposed abstraction doesn't meet the minimum threshold of usefulness.</span></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; "><br></span></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; ">Your idea may be valid and useful in other contexts, but named tuples aren't a good motivating use case, IMO.</span></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; "><br></span></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; "><br></span></span></div><div><span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px; "><span class="Apple-style-span" style="font-family: Helvetica; line-height: normal; font-size: medium; ">Raymond</span></span></div><div><br></div><div><br></div><div>P.S.  The current approach to assignments has the virtue that it is readable to people coming from other languages.  The decorator approach creates a piece of Python arcana that would only be decipherable to a smaller number of people.</div><div><br></div></body></html>