Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, Python supports in place operators to avoid this:

    def __iadd__(self, other):
        if isinstance(other, dict):
            self.update(other)
            return self
This would get called for `d += other`.


My follow up question would be why not do this for both union functions? I don’t see why they would want to have two functions that do the exact same thing (called differently, though) be written in two different ways.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: