Skip to content

Comment on Python bug: Can assign [] = (), but not () = []parent

Comments

The tricky part is that the [a,b] and (a,b) in your original examples are not list/tuple literals, but a target_list according to Python's grammar [0], which can be optionally enclosed in parentheses or brackets. To be honest, I didn't know the latter were allowed, even though I've been using Python for years. IMHO, they should have just allowed parentheses. It's like the parentheses in function calls--not really a tuple, but syntactic grouping. Why have more that one way to do the same thing?

[0]: https://docs.python.org/3/reference/simple_stmts.html#assign...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.