Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 4
    Works fine in Python 3 and PyPy and PyPy 3, can't speak to Jython or Iron. Given this pattern is explicitly documented (see the third constructor form in this documentation) I'd argue it's not an "implementation detail" but intentional feature use.
    – amcgregor
    Commented Apr 12, 2019 at 13:10
  • 19
    @amcgregor You missed the key phrase "if y has any non-string keys." That's what doesn't work in Python3; the fact that it works in CPython 2 is an implementation detail that can't be relied on. IFF all your keys are guaranteed to be strings, this is a fully supported option.
    – Carl Meyer
    Commented May 10, 2019 at 16:27