FEEDBACK WANTED: Type/class unification
Roman Suzi
rnd at onego.ru
Wed Aug 1 18:02:26 EDT 2001
On Sat, 28 Jul 2001, Paul Prescod wrote:
>William Tanksley wrote:
>>
>> On Sat, 28 Jul 2001 13:07:32 -0700, Paul Prescod wrote:
>> >2. If I have an object that hides its attributes behind an __getattr__,
>> >is there any way to tweak the list returned by the API described above?
>>
>> Not without the object's cooperation -- it's not even theoretically
>> possible to figure out what attributes __getattr__ might support.
>
>I am asking whether there is a way for the object to cooperate.
>
>>...
>> >def attrs(x):
>> > return [y for y in all_possible_strings if hasattr(x, y)]
>>
>> Yes, that would work, for certain values of "work". all_possible_strings
>> is a pretty simple generator. So is attrs(), actually.
>>
>> def attrs(x):
>> for y in all_possible_strings():
>> if hasattr(x,y): yield y
>>
>> Amusing.
>
>I wasn't being theoretical. I was asking whether there is a function,
>method or parameter with those semantics (and obviously a more sane
>implementation).
This reminds me of the WWW becoming more and more virtual:
http://aaa.bbb.ccc/some/path
no more means there is aaa.bbb.ccc server with
some/path file on it's HD...
Does it harm WWW introspection (aka search engines)? Yes, it does. But it
is up to the web-master to decide how to let the site to be searchable.
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Wednesday, August 01, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Be nice to other people, they outnumber you 5.5 billion to 1." _/
More information about the Python-list
mailing list