Python language suggestion
Quinn Dunkan
quinn at euro.ugcs.caltech.edu
Mon Jan 15 02:51:07 EST 2001
On Sat, 13 Jan 2001 15:44:46 -0800, Chris Ryland <cpr at emsoftware.com> wrote:
>Actually, this brings up an interesting point.
>
>Why doesn't the attribute reference (primary "." identifier) work for any
>dictionary-like object?
>
>E.g., why doesn't
>
>f = {'a': 1, 'b': 2}
>print f.a
>
>work while
>
>f['a']
>
>does? (I mean from a language design standpoint, not why doesn't it work
>currently.)
Well, as others have pointed out, there's an important difference between
instance attributes and dictionary entries in python. Incidentally, there's a
language called 'lua' which is very similar to python, except that 'foo.bar'
is sugar for "foo['bar']". There are a few other differences, of course :)
Naturally, lua tables don't have methods like python dicts.
More information about the Python-list
mailing list