2010/8/23 Michael Foord <fuzzy...@voidspace.org.uk>:
>  On 23/08/2010 23:55, Benjamin Peterson wrote:
>>
>> 2010/8/23 Raymond Hettinger<raymond.hettin...@gmail.com>:
>>>
>>> On Aug 23, 2010, at 1:13 PM, Benjamin Peterson wrote:
>>>
>>>> 2010/8/23 Michael Foord<fuzzy...@voidspace.org.uk>:
>>>>>
>>>>> To me hasattr *looks* like a passive introspection function, and the
>>>>> fact
>>>>> that it can trigger arbitrary code execution is unfortunate -
>>>>> especially
>>>>> because a full workaround is pretty arcane.
>>
>> hasattr(x, "y") doesn't look any more passive to me the x.y.
>
> One says "does this object have attribute y" the other fetches attribute y.
> I'm amazed they don't look different to you. Given Python's object model
> there is no reason that the first *should* fetch the attribute to determine
> that it is present, *except* for the dynamic attribute creation of
> __getattr__ and __getattribute__.

Actually, I'd say given Python's object model, you have to have the
attribute in hand to determine that it is present.

>
> For properties there is *no reason* why code should be executed merely in
> order to discover if the attribute exists or not.

Properties are allowed to raise AttributeError, so you technically
have to execute it.



-- 
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to