<br><br><div class="gmail_quote">On 7 June 2010 12:06, Masklinn <span dir="ltr"><<a href="mailto:masklinn@masklinn.net">masklinn@masklinn.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 2010-06-07, at 12:51 , George Sakkis wrote:<br>
><br>
> I'm wondering if there is any downside in making properties callable:<br>
</div>It already exists, it's called a method.<br>
<br>
Due to the way calling works in Python (you get a callable object and<br>
 you apply the `()` operator to it) I don't think it's possible to<br>
discriminate based on the context to perform the same operation<br>
whether or not the value is called.<br>
<br>
Your best bet would probably be to wrap the output of the property<br>
in a subtype of itself (dynamically created subtype) able to return<br>
self on call. Or you just create a lambda wrapping the property call.<br></blockquote><div><br>I think you misunderstood, he was suggesting making the property descriptor instances callable. <br><br>Not a bad idea, but as a change to a builtin it would be covered by the language moratorium. Easy to do in a subclass of property though. <br>
<br>At the moment you do the following, which is a bit ugly:<br><br>>>> class Foo(object):<br>...  @property<br>...  def foo(self):<br>...   return 'foo'<br>... <br>>>> f = Foo()<br>>>> Foo.foo.__get__(f)<br>
'foo'<br><br>The reason for wanting to do this are the same reasons as you would call an unbound method.<br><br>Michael<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5"><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.voidspace.org.uk">http://www.voidspace.org.uk</a><br><br><br>