From: Ivan V. i B. <iv...@ca...> - 2005-01-20 14:51:26
|
On Wed, Jan 19, 2005 at 02:50:56PM +0100, Norbert Nemec wrote: > Am Mittwoch, 19. Januar 2005 09:34 schrieb Ivan Vilata i Balaguer: > > On Mon, Jan 17, 2005 at 09:17:08AM +0100, Norbert Nemec wrote: [...] > Seems to me that you are cofusing __getattr__ and __getitem__ - the latte= r has=20 > nothing to do with key completion. if you start with > something[" > and hit TAB, nothing will happen, no matter which IDE or shell you use. >=20 > Key-completion only works for natural naming. Most shells simply use __di= ct__=20 > to find out what to offer for completion. It is true, that eric seems to = have=20 > some additional place to look for but that does not affect this discussio= n. I may have not been clear enough, but I was not mixing __getattr__ and __getitem__. In fact, Eric 3 *does* show completions for this: >>> d =3D {'foo': 1, 'bar': 10, 'foobar': 20} >>> d["fo But, as you say, this does not affect the discussion, which is mainly about __dict__ and __*attr__ behavior. >=20 > To sum up: > * __dict__ should contain only the immediate children. It is not clear ye= t,=20 > whether it should only contain the pythonic names or all names. > * __getitem__ and __getattr__ might well allow additional keys that are n= ot=20 > advertised in __dict__: these will not show up for key-completion but the= y=20 > will work nontheless. > * it might make sense to do '/' parsing in __getitem__, such that > something["abc/djk"] > is internally read equivalently to > something["abc"]["djk"] > or > something.abc.djk > Of course, "abc/djk" should not appear in __dict__ [...] I agree with these three points and the lack of utility of completing non-pythonic names. However, not completing a non-pythonic name may give the impression that the name does not exist! Hopefully, the user should stop at this point, print the node, see that the named child exists and use [] notation instead (or go for the manual to see what is happening). It seems coherent to me. Bye! import disclaimer --=20 Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C=E1rabos Coop. V. V V Enjoy Data "" |