From: Francesc A. <fa...@ca...> - 2004-12-13 18:31:27
|
A Dilluns 13 Desembre 2004 18:53, Norbert Nemec va escriure: > Using SyntaxError for non-pythonic identifiers is a nice idea, even thoug= h it=20 > should be noted that the following code: >=20 > ---------- > class A: > pass > a=3DA() > setattr(a,"!$%#**",42) > print a.__dict__ > ---------- >=20 > works fine and gives: >=20 > {'!$%#**': 4} >=20 > This attribute is therefore inaccessible by natural naming but still lega= l.=20 > Shouldn't pytables behave the same? I don't think so. Allowing that kind of identifiers would break natural naming and that should be avoided for the sake of usability. > In any case, the correct error to raise in the first case would seem to b= e=20 > ValueError. >=20 > I'm really confused now. Anybody has better ideas? Well, IMO NameError is the exception name that better fits in this case (much better that SyntaxError). However, I guess that something like a new NodenameError would be the best.=20 We have to decide however, what to do with attribute names. Should we allow beasts like "!$%#**", or they should be avoided at all? and... should we issue a different exception in case of bad attribute names like AttrnameError? My opinion is that "!$%#**" beasts should be avoided and that introducing an AttrnameError would be nice. Perhaps Ivan have more ideas on that. Cheers, =2D-=20 =46rancesc Altet Who's your data daddy? =A0PyTables |