From: Norbert N. <Nor...@gm...> - 2005-01-16 13:30:44
|
Hi there, an idea that I have carried around for some time now: I know that natural naming is seen as one of the important features of pytables. For interactive use, this certainly is true. For me - mainly using scripts - it gets in the way quite often. I'm using getattr/setattr more often than natural naming, since the attribute names are quite often handled as strings. How about generally defining __???item__ in parallel to the corresponding __???attr__ ? mygroup["mynode"] = Node(...) print mygroup["mynode"] del mygroup["mynode"] would be identical to mygroup.mynode = Node(...) print mygroup.mynode del mygroup.mynode in case nodename == "mynode" mygroup[nodename] = Node(...) print mygroup[nodename] del mygroup[nodename] certainly is nicer than setattr(mygroup,nodename,Node(...)) print getattr(mygroup,nodename) delattr(mygroup,nodename) especially, since you are not dealing with an HDF5-Attribute (!!!) In a further step, it might even be a good idea, to make __???item__ the standard way that is used everywhere within the pytables library and __???attr__ just an additional option falling back to __???item__ This would probably beautify the library code quite a bit (getattr/setattr are called quite often) but even more important: it would releave the name conflict of 'Python-attributes' vs. 'HDF5-Attributes'. Instead of thinking of 'Python-attributes', one would think of 'items' which may be either 'Attributes' or 'Nodes'. Greetings, Norbert -- _________________________________________Norbert Nemec Bernhardstr. 2 ... D-93053 Regensburg Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199 eMail: <No...@Ne...> |