From: Norbert N. <Nor...@gm...> - 2004-12-10 14:42:15
|
Am Freitag, 10. Dezember 2004 09:39 schrieb Francesc Altet: > A Divendres 10 Desembre 2004 08:23, Norbert Nemec va escriure: > > > However, at a Python level, nodes are accessed as attributes (or > > > members), so the right exception should be AttributeError. If we > > > want to give this kind of access an additional meaning in PyTables, > > > then maybe a new subclass of AttributeError (e.g NodeError) should be > > > defined and used instead. In addition, this would not break > > > compatibility with existing code where AttributeError was caught. Well, > > > this is just an alternative. Bye! > > > > I like this idea. > > Yes, me too. However, that implies a few more more work, and perhaps a > better redesign of *many* others exceptions in PyTables. While this a task > that should be done, I'm still very tempted to use a KeyError, just to > diferentiate behaviours. Although perhaps is still better to let the > current LookupError (__getattr__ and __delattr__) and NameError > (__setattr__) happening until the big exception redesing would happen. OK, doing a quick grep through the sources, I realize that there is quite some work to do. I don't know enough about the general state of exceptions in pytables to really estimates what has to be done. I would suggest that the better solution than "abusing" KeyError, LookupError and NameError would be to define new exceptions somewhere (NodeError was suggested by Ivan, maybe additional ones unless you want to merge all node-errors together) and do a plain search and replace. With NodeError inheriting AttributeError, this would have the immediate advantage of fixing hasattr (which should definitely work for nodes as well, since they are defined using __setattr__/__getattr__) -- _________________________________________Norbert Nemec Bernhardstr. 2 ... D-93053 Regensburg Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199 eMail: <No...@Ne...> |