Jim Fulton wrote:
I would change it to just use getattr rather than hasattr.
try:
getattr(ob, name)
except AttributeError:
return False
...
Given the controversy about our original proposal, I think I'll just
implement Jim's suggestion. I'll do so as soon as possible.
--
Thomas
On Thu, Oct 23, 2008 at 08:57:30AM +0200, Thomas Lotze wrote:
Jim Fulton wrote:
I would change it to just use getattr rather than hasattr.
try:
getattr(ob, name)
except AttributeError:
return False
...
Given the controversy about our original proposal, I think I'll
Tres Seaver wrote at 2008-10-17 15:14 -0400:
...
verifyObject/verifyClass is likely not to handle the following
case correctly:
class I(Interface):
def m(...):
...
class C(object):
implements(I)
m = property(lambda self: lambda ...: ...)
Christian Theune wrote at 2008-10-16 20:27 +0200:
...
Then again, verifyObject is a *very* light way to spot simple errors.
IMHO attributes and methods aren't that different in Python, as using
both may result in exceptions.
Using attributes (not computed one) does not result in exceptions.
Dieter Maurer [EMAIL PROTECTED] schrieb:
And if the attribute is implemented by a property (of the class, i.e.
the decriptor is on the metaclass), then the descriptors __get__
is called (in the same way as for verifyObject).
Instance properties (descriptor on the class) may not define methods
Thomas Lotze wrote at 2008-10-16 20:57 +0200:
Christian Theune [EMAIL PROTECTED] wrote:
Arguably, the check for an attribute would be sufficient if it checked
whether an attribute implementation is around -- either by a simple
attribute value or a descriptor providing that.
At this point, I
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Dieter Maurer wrote:
Thomas Lotze wrote at 2008-10-16 20:57 +0200:
Christian Theune [EMAIL PROTECTED] wrote:
Arguably, the check for an attribute would be sufficient if it checked
whether an attribute implementation is around -- either by a
Thomas Lotze wrote at 2008-10-17 19:42 +0200:
Dieter Maurer [EMAIL PROTECTED] schrieb:
...
Instance properties (descriptor on the class) may not define methods
(probably a bug).
I don't understand what you're saying in that last sentence; can you
elaborate?
verifyObject/verifyClass is likely
Dieter Maurer [EMAIL PROTECTED] schrieb:
verifyObject/verifyClass is likely not to handle the following
case correctly:
class I(Interface):
def m(...):
...
class C(object):
implements(I)
m = property(lambda self: lambda ...: ...)
i.e. when
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Dieter Maurer wrote:
Thomas Lotze wrote at 2008-10-17 19:42 +0200:
Dieter Maurer [EMAIL PROTECTED] schrieb:
...
Instance properties (descriptor on the class) may not define methods
(probably a bug).
I don't understand what you're saying in that
Tres Seaver [EMAIL PROTECTED] schrieb:
Dieter Maurer wrote:
class C(object):
implements(I)
m = property(lambda self: lambda ...: ...)
i.e. when a method (declared by the interface) is implemented by a property.
Why would I want to do that, rather than using
Thomas Lotze wrote at 2008-10-15 20:55 +0200:
Dieter Maurer [EMAIL PROTECTED] wrote:
I fear your must describe your proposed change more precisely:
Nothing to be afraid of here ;o)
When your problem is the stated use case: verifyObject fails
because something necessary for the interface
Hi,
On Thu, 2008-10-16 at 18:45 +0200, Dieter Maurer wrote:
I do not follow your argumentation: An attribute it not there because
there is a descriptor, it is only there when the descriptor provides
a value: I have seen descriptors in Zope3 that are only there to
remove
an attribute that
Christian Theune [EMAIL PROTECTED] wrote:
Arguably, the check for an attribute would be sufficient if it checked
whether an attribute implementation is around -- either by a simple
attribute value or a descriptor providing that.
At this point, I guess the outcome of the discussion depends on
On Oct 15, 2008, at 3:27 AM, Thomas Lotze wrote:
There has been a problem with zope.interface's verifyObject function
that occurs in conjunction with Python properties: when verifyObject
checks for the presence of an object's attribute, it does so by using
hasattr() which in turn tries a
Jim Fulton [EMAIL PROTECTED] wrote:
I would change it to just use getattr rather than hasattr.
try:
getattr(ob, name)
except AttributeError:
return False
...
This doesn't handle the case that the attribute exists as a property
but raises an AttributeError when trying to produce
Thomas Lotze wrote:
Jim Fulton [EMAIL PROTECTED] wrote:
I would change it to just use getattr rather than hasattr.
try:
getattr(ob, name)
except AttributeError:
return False
...
This doesn't handle the case that the attribute exists as a property
but raises an AttributeError
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Thomas Lotze wrote:
Jim Fulton [EMAIL PROTECTED] wrote:
I would change it to just use getattr rather than hasattr.
try:
getattr(ob, name)
except AttributeError:
return False
...
This doesn't handle the case that the attribute
Thomas Lotze wrote at 2008-10-15 09:27 +0200:
There has been a problem with zope.interface's verifyObject function
that occurs in conjunction with Python properties: when verifyObject
checks for the presence of an object's attribute, it does so by using
hasattr() which in turn tries a getattr()
19 matches
Mail list logo