Are there any reserved kwargs for the python dict builder?

advertisements

When using the kwarg-style dict initialization:

In [3]: dict(a=1, b=2, c=3)
Out[3]: {'a': 1, 'b': 2, 'c': 3}

for some reason, defining the key 'from' raises a syntax error:

In [4]: dict(to=0, from=1)
------------------------------------------------------------
   File "<ipython console>", line 1
     dict(to=0, from=1)
                   ^
SyntaxError: invalid syntax

What is special about the key 'from'? Are there any other reserved keys for the kwarg-style initialization?

I am using Python 2.6.


from is used in imports.

Python Language Reference, ยง2.3.1, "Keywords"

Note that you can still use kwarg expansion to get them through though.