Learning about dictionaries

Fredrik Lundh fredrik at pythonware.com
Fri Apr 16 13:18:47 EDT 2004


Thomas Philips wrote:
> I'm teaching myself python and in the course of playing around with
> dictionaries, I tried to create the following trivial dictionary
>
> {1:'one', 2:'two'}

that's a dictionary, right.

(to be precise, it's a "dictionary display" which is how you enter
"dictionary values" in Python source code)

> So I entered
> >>> dict(1='one',2='two')

that's not a dictionary, that's a function call.

you're trying to call a function called "dict" with two keyword arguments,
but your keywords doesn't match Python's identifier syntax.

more here:

    http://docs.python.org/ref/calls.html
    http://docs.python.org/ref/dict.html

</F>







More information about the Python-list mailing list