9 ms·
> my freshest student in front of a code and see how they deal with it. That is fine if you want to optimize language for "fresh students". That is not represe
by llukas 7y ago
> my freshest student in front of a code and see how they deal with it.
That is fine if you want to optimize language for "fresh students". That is not representative how brain process stuff after getting even some experience.
- mbreese 7y agoIt's not about experience vs inexperience... it's about code readability and being unsurprising. m = re.match(...) if m: ... do something ... is verbose, but quite readable. Given that it's the way things have been done since forever, it's also unsurprising. if m := re.match(...): ... do something ... Without knowing what the walrus operator is, it is not entirely clear what is going on here. := is only syntactic sugar, which is not what Python has ever been about.
- owaislone 7y agoIf feel Go solves this in a much more readable way. if m := re.match(...); m { ... do something ... } Still not as readable as splitting it over multiple lines but quite a lot better than Python's syntax IMO especially once you learn how the if statement works in Go.
- mkl 7y agoHow is that more readable? It's identical except for ":" -> ";", and some extra symbols added. Needing to repeat "m" seems seems redundant, and particularly bad for readability as it moves the actual condition far away from the "if".
- owaislone 7y agoIt is better IMO because it doesn't merge two things into one. It simply translates to `if <assignment>; <condition> { <body> }` as a generic rule. Variable used in condition may or may not be the same one in assignment. Bundling assignment and condition is what people don't like about this feature.
- clinta 7y agoPython already has " as " operator that I think is very readable. with open('file') as f: ... do something ... I don't know why that didn't come out on top in the debate. if re.match(...) as m: ... do something ...
- sametmax 7y agoIt's not, it's correlation between fresh student, and what happens in the field.