A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040414.html below:

[Python-Dev] string-valued fget/fset/fdel for properties

[Python-Dev] string-valued fget/fset/fdel for properties [Python-Dev] string-valued fget/fset/fdel for propertiesEdward Loper edloper at gradient.cis.upenn.edu
Mon Nov 24 04:35:33 EST 2003
Guido van Rossum wrote:
>>     1. It's easier to read.  (In my opinion, anyway; what do other
>>        people think?)
> 
> Only if you're used to the new syntax.  Otherwise it could mean a
> costly excursion into the docs.
 > [...]
 >>     - It's one more special case to document/know.
 >
 > Right.  It feels like a hack.

To me it seems like the "obvious" behavior for a string fget/fset/fdel, 
but if it's not universally obvious than you're proably right that it's 
a bad idea to add it.

> but I've got a suspicion you want to combine some string argument
> (most likely for fget) with some function argument.

Yes, the idea was that some properties only redirect on read, or only on 
write; and that the syntax could be made "cleaner" for those cases.

 > I'm curious about the use case that makes you feel the need for speed.
 > I would expect most properties not to simply redirect to another
 > attribute, but to add at least *some* checking or other calculation.

The primary motivation was actually to make the code "easier to read"; 
the speed boost was an added bonus.  (Though not a trivial one -- I do 
have a good number of fairly tight loops that access properties.)  The 
use case that inspired the idea is defining read-only properties for 
immutable objects.  But I guess I would be better off going with wrapper 
functions that create the read-only properties for me (like 
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157768>).

Thanks for the feedback!

-Edward



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4