Re:PEP 308 and why I still hate Python
by dragonwriter on Friday March 10, 2017 @07:24PM
(#13843333)
> When I hit the opening bracket, I don't know whether I'm looking at an array literal or a comprehension. I have to read ahead a few tokens to disambiguate.
All research I have seen says that proficient readers of a language read closer to a line at a time than a token at a time, so I suspect that not really a problem so much as a rationalization of aesthetic preference.
> bonus reason: why not `list(baz)`? Is there actually some logic to when Python uses methods and when it uses global functions?
list is a built-in type, and (as is usually the case for Python types) list() is the type constructor. There are other global functions in Python and there is room for debate over whether they make sense over methods, but constructors for built-types are pretty clear.
baz.list() is a method on baz. Assuming baz is iterable, list(baz) is valid, it's just different than baz.list().
All research I have seen says that proficient readers of a language read closer to a line at a time than a token at a time, so I suspect that not really a problem so much as a rationalization of aesthetic preference.
> bonus reason: why not `list(baz)`? Is there actually some logic to when Python uses methods and when it uses global functions?
list is a built-in type, and (as is usually the case for Python types) list() is the type constructor. There are other global functions in Python and there is room for debate over whether they make sense over methods, but constructors for built-types are pretty clear.
baz.list() is a method on baz. Assuming baz is iterable, list(baz) is valid, it's just different than baz.list().