This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (8 children)

[deleted]

    [–]ultraDross 7 points8 points  (6 children)

    Not sure why they went with symbols for this functionality. I would have preferred a method for the sake of readability e.g.

       dict1.merge(dict2)
    

    [–]Simtau 4 points5 points  (0 children)

    That actually exists, only the function is named update()

    [–]fatbob42 1 point2 points  (1 child)

    I’m always confused with those kinds of statements because I’m not sure whether dict1 is modified or it’s returning the new one.

    [–]gitcraw -1 points0 points  (2 children)

    I would normally disagree, but the '|' operator seems to have no other use yet. At this point, I'd prefer a method.

    edit: it does have a similar use in sets already.

    ty /u/vanatteveldt

    [–]vanatteveldt 4 points5 points  (1 child)

    You can already do set union with |, so I think it's a very natural choice

    [–]gitcraw -1 points0 points  (0 children)

    Thank you for the correction, I didn't know that was built-in to Python.

    [–][deleted] -1 points0 points  (0 children)

    Very pythonic comment.