En/na Andrew Straw ha escrit::

> Hi Ivan (and Francesc), thanks for your responses on this (on my other!)
> issues... You are very helpful, as always.
> 
> I understand the logic well enough. My point is that it's simply very
> confusing that a child node sometimes counts as an attribute (getattr)
> and sometimes does not (setattr, delattr). I can live with the issue now
> that I understand it. My suggestion is meant to help those with less
> understanding of PyTables than I now have (me 3 days ago would be an
> example of such a person). It seems to me that __setattr__ and
> __delattr__, before raising an AttributeError, could at least check if
> there's a child node by the name and raise something other than an
> AttributeError (ChildNodeIsNotPythonAttributeError even, if you like.) I
> think the performance penalty would be negligible (it's only in an
> error-path) and the clarity benefit would be significant.

I agree that giving the extra info is nice to the user, but I refrain
from using something other that a plain AttributeError in the
__delitem__() case, since it is just following the expected Python
behaviour (same goes for __setitem__()).

Using a subclass of AttributeError would be needed to tell the
particular case you exposed apart from others inside a program, but then
the programmatic interface (i.e. node._f_remove() or file.removeNode(),
which don't suffer from this problem) should have been used anyway.

Thus, I have tailored the AttributeError in Group.__delitem__() to be a
little more explanatory in the general case.  It is revision 1565 (you
can have a look at it at https://pytables.org/trac/changeset/1565).

Thanks for your suggestions!

::

        Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
               Cárabos Coop. V.  V  V   Enjoy Data
                                  ""

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to