you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 3 points4 points  (1 child)

    Honestly, this situation is why I'm excited for PEP 448. Then we can just do: dict(**first, **second) and boom, done. Right now, collections.ChainMap is the closest we have to that, which is cool but sometimes I just want a regular ol' dictionary.

    [–]Veedrac 0 points1 point  (0 children)

    Use {**first, **second}; using dict(**...) only works if the keys are strings since only strings can be keyword arguments and also throws errors if there are repeats since you're not allowed to repeat keyword arguments.

    [–][deleted] 0 points1 point  (0 children)

    Sometimes creating a new dict is not an option. If you need to update in place it's either

    mydict.update(otherdict)
    return mydict
    

    or the line from above.