Julien wrote:
> What I'd like to achieve is:
>
d = {
> ... 'a': 1,
> ... 'b': 2,
> ... 'a': 3
> ... }
> Error: The key 'a' already exists.
>
> Is that possible, and if so, how?
Not if the requirements including using built-in dicts { }.
But if you are happy enough to use a custom cl
Hi,
With a simple dict, the following happens:
>>> d = {
... 'a': 1,
... 'b': 2,
... 'a': 3
... }
>>> d
{'a': 3, 'b': 2}
... i.e. the value for the 'a' key gets overridden.
What I'd like to achieve is:
>>> d = {
... 'a': 1,
... 'b': 2,
... 'a': 3
... }
Error: The key 'a' already ex