<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: About getters and setters in Python</title>
	<atom:link href="http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/feed" rel="self" type="application/rss+xml" />
	<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=about-getters-and-setters-in-python</link>
	<description>still in love with underscores</description>
	<lastBuildDate>Mon, 16 Jan 2012 02:10:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: UncleZeiv</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-11795</link>
		<dc:creator>UncleZeiv</dc:creator>
		<pubDate>Thu, 29 Sep 2011 00:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-11795</guid>
		<description>&lt;a href=&quot;#comment-8807&quot; rel=&quot;nofollow&quot;&gt;@Sean&lt;/a&gt; 
Thanks for pointing that out, although I think my main point still stands: for class hierarchies, proper getters and setters are just syntactically cleaner and easier to understand.

&lt;a href=&quot;#comment-11789&quot; rel=&quot;nofollow&quot;&gt;@Erik Bray&lt;/a&gt; 
Ah that&#039;s interesting, thanks for sharing! And again, it&#039;s an additional reason not to fiddle with properties in a class hierarchy if not necessary.

In the end I think class hierarchies are falling out of fashion, and in Python this is particularly true because duck typing is more general than inheritance-based polymorphism... So I guess this is why some mechanisms are not entirely orthogonal with respect to inheritance - in other words nobody cares. That&#039;s fine by me but then again I just wish Pythoners were not so smug in dismissing the use of getters and setters, as there are clearly cases for those...</description>
		<content:encoded><![CDATA[<p><a href="#comment-8807" rel="nofollow">@Sean</a><br />
Thanks for pointing that out, although I think my main point still stands: for class hierarchies, proper getters and setters are just syntactically cleaner and easier to understand.</p>
<p><a href="#comment-11789" rel="nofollow">@Erik Bray</a><br />
Ah that&#8217;s interesting, thanks for sharing! And again, it&#8217;s an additional reason not to fiddle with properties in a class hierarchy if not necessary.</p>
<p>In the end I think class hierarchies are falling out of fashion, and in Python this is particularly true because duck typing is more general than inheritance-based polymorphism&#8230; So I guess this is why some mechanisms are not entirely orthogonal with respect to inheritance &#8211; in other words nobody cares. That&#8217;s fine by me but then again I just wish Pythoners were not so smug in dismissing the use of getters and setters, as there are clearly cases for those&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Bray</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-11790</link>
		<dc:creator>Erik Bray</dc:creator>
		<pubDate>Wed, 28 Sep 2011 17:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-11790</guid>
		<description>Though it seems this quirk is actually a &quot;feature&quot;.  See: http://bugs.python.org/issue505028

I guess the answer is to not use super, and instead use the kludgy Foo.foo.fget/Foo.foo.fset.

It&#039;s claimed that data descriptors shouldn&#039;t be overridden by a subclass, but I can&#039;t see what the justification is for that proclamation.  There are perfectly good reasons to do this.</description>
		<content:encoded><![CDATA[<p>Though it seems this quirk is actually a &#8220;feature&#8221;.  See: <a href="http://bugs.python.org/issue505028" rel="nofollow">http://bugs.python.org/issue505028</a></p>
<p>I guess the answer is to not use super, and instead use the kludgy Foo.foo.fget/Foo.foo.fset.</p>
<p>It&#8217;s claimed that data descriptors shouldn&#8217;t be overridden by a subclass, but I can&#8217;t see what the justification is for that proclamation.  There are perfectly good reasons to do this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Bray</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-11789</link>
		<dc:creator>Erik Bray</dc:creator>
		<pubDate>Wed, 28 Sep 2011 17:13:17 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-11789</guid>
		<description>I recently encountered this problem--not for the first time in general, but the first time in which setters are involved.

Sean mentioned above that you can user super() to access the the property through the base class:

super(Bar, self).foo

This has always worked for me.  But interestingly, if I try to override a setter and I do:

@foo.setter
def foo(self, value):
    super(Bar, self).foo = value

It explodes with an AttributeError, claiming that the super object has no attribute &#039;foo&#039;.  I guess this has something to do with super.__setattr__, but I&#039;m not sure.  I&#039;d consider this a bug though.  Either one should work or neither should work.</description>
		<content:encoded><![CDATA[<p>I recently encountered this problem&#8211;not for the first time in general, but the first time in which setters are involved.</p>
<p>Sean mentioned above that you can user super() to access the the property through the base class:</p>
<p>super(Bar, self).foo</p>
<p>This has always worked for me.  But interestingly, if I try to override a setter and I do:</p>
<p>@foo.setter<br />
def foo(self, value):<br />
    super(Bar, self).foo = value</p>
<p>It explodes with an AttributeError, claiming that the super object has no attribute &#8216;foo&#8217;.  I guess this has something to do with super.__setattr__, but I&#8217;m not sure.  I&#8217;d consider this a bug though.  Either one should work or neither should work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-8807</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Fri, 11 Mar 2011 19:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-8807</guid>
		<description>In your first example, you could use super():
class Bar(Foo):
    @property
    def foo(self):
        return super( Bar, self).foo + 1

this way you don&#039;t need know if the attribute is a property instance

And in your second example, knowing it is a property, you can override the getter with:
class Bar(Foo):
    @Foo.foo.getter
    def foo( self ):
    	return super( Bar, self).foo + 1


This works for me in py2.6.5, obviously your article was from some time ago, I am not sure when exactly this became effective.</description>
		<content:encoded><![CDATA[<p>In your first example, you could use super():<br />
class Bar(Foo):<br />
    @property<br />
    def foo(self):<br />
        return super( Bar, self).foo + 1</p>
<p>this way you don&#8217;t need know if the attribute is a property instance</p>
<p>And in your second example, knowing it is a property, you can override the getter with:<br />
class Bar(Foo):<br />
    @Foo.foo.getter<br />
    def foo( self ):<br />
    	return super( Bar, self).foo + 1</p>
<p>This works for me in py2.6.5, obviously your article was from some time ago, I am not sure when exactly this became effective.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: UncleZeiv</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-3846</link>
		<dc:creator>UncleZeiv</dc:creator>
		<pubDate>Thu, 27 Aug 2009 22:41:59 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-3846</guid>
		<description>&lt;a href=&quot;#comment-3842&quot; rel=&quot;nofollow&quot;&gt;@PJ Eby&lt;/a&gt; 
Interesting solution, it didn&#039;t occur to me... it could indeed solve my problems.

(Thanks for commenting, I really appreciated it.)</description>
		<content:encoded><![CDATA[<p><a href="#comment-3842" rel="nofollow">@PJ Eby</a><br />
Interesting solution, it didn&#8217;t occur to me&#8230; it could indeed solve my problems.</p>
<p>(Thanks for commenting, I really appreciated it.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PJ Eby</title>
		<link>http://unclezeiv.kerid.org/2009/08/about-getters-and-setters-in-python/comment-page-1#comment-3842</link>
		<dc:creator>PJ Eby</dc:creator>
		<pubDate>Thu, 27 Aug 2009 14:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://unclezeiv.kerid.org/?p=91#comment-3842</guid>
		<description>If the properties aren&#039;t performance-critical, you can always make the property in the base class be property(lambda s:s.get_foo(), lambda s,v: s.set_foo(v)).  Then, simply override the getter or setter in the subclass(es) involved.

In any case, there are plenty of worse ways that changes to a base class can impact a subclass; subclassing is inherently a tighter coupling between classes than mere use.</description>
		<content:encoded><![CDATA[<p>If the properties aren&#8217;t performance-critical, you can always make the property in the base class be property(lambda s:s.get_foo(), lambda s,v: s.set_foo(v)).  Then, simply override the getter or setter in the subclass(es) involved.</p>
<p>In any case, there are plenty of worse ways that changes to a base class can impact a subclass; subclassing is inherently a tighter coupling between classes than mere use.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

