properties and get/set methods

Mike C. Fletcher mcfletch at rogers.com
Sun Apr 6 11:56:49 EDT 2003


Jp Calderone wrote:

>On Sat, Apr 05, 2003 at 11:48:41PM -0500, Mike C. Fletcher wrote:
>  
>
>>Dan Bishop wrote:
>>    
>>
... heavily edited, there's more byplay here...

>>>Why not just use two different getvar and setvar functions?
>>>      
>>>
... heavily edited, there's more byplay here...

>  Indeed not.  So move things around a little:
>
... neat embed-with-namespaces hack snipped ...

>  Logically, the two layers still exist (good thing), but the first is
>resolved entirely at class-creation time, nicely negating the efficiency
>concerns (good thing).
>
Very nice.  Don't think I'll actually adopt it directly (I prefer a 
classical OO derived-class approach), but definitely a neat approach.  
In the end, it would push all the data (e.g. type declarations, watching 
mechanisms) down into the functions, which should make for fast 
operation, but would likely make the normal introspection mechanisms 
take a fit (well, actually just "do nothing") when trying to describe 
the properties.  I'd looked at define-time-binding the methods of the 
property objects, but it wasn't a noticable win compared to the work the 
methods themselves were doing.

Interesting though, especially for the original poster, where there's 
only a single attribute type ("generic"), so introspection won't matter 
much.

Enjoy,
Mike

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/








More information about the Python-list mailing list