2010/8/23 Michael Foord <fuzzy...@voidspace.org.uk>:
> Properties are allowed to do whatever the heck they want. That doesn't mean
> that you have to execute code to determine whether they exist or not.

I thought you were trying to determine whether the attribute exists
not the property.
>
> If fetching an attribute raises an AttributeError it doesn't mean that
> attribute doesn't exist (although I admit that at the moment this is exactly
> what hasattr uses to mean) it just means that fetching that attribute raised
> an AttributeError. Even if you allow other exceptions to propagate you are
> still left with the fact that an AttributeError raised as a bug will still
> be silenced and interpreted as meaning that hasattr should just return
> False.

Raised as a bug? Is this not a valid pattern?

@property
def myprop(self):
    if not self.myprop_support:
        raise AttributeError("myprop")



-- 
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