Dynamic attribute introspection

Andrew Dalke dalke at acm.org
Mon Aug 13 17:17:27 EDT 2001


Guido:
>With the new class system, many uses of __getattr__ can be replaced by
>descriptors for get/set attributes; see the section "Attributes
>defined by get/set methods" in the tutorial mentioned above.

Looking at the tutorial, I note that the 'getset' mentioned there
wouldn't trivially [*] work for one __getattr__/__setattr__ solution
I developed.  In that case, there was a write-only attribute,
where you could set it but not read from it.

Granted, such things aren't very common, but it might be useful
to consider that a default 'getset' may need to allow a 'get = None'.
This is especially relevant if indeed it does "become a built-in type
in 2.2a2."

[*] By trivial I know that one simple solution is to write my own
getset equivalent.

                    Andrew
                    dalke at dalkescientific.com








More information about the Python-list mailing list