3 ms·
Python has lots of weird operators. List/dict comprehension, list slicing, * and in arguments. Comma for tuples (which make sense to me, but add a lot of magi
by dkersten 10y ago
Python has lots of weird operators.
List/dict comprehension, list slicing, * and in arguments. Comma for tuples (which make sense to me, but add a lot of magic, especially since, in my experience, beginners often assume that the parentheses are what make tuples). There's many more examples, but those are the ones that immediately spring to mind.
Reading actual production Python code is not any easier than many other languages and certainly far from "executable pseudocode"
- guitarbill 10y agoThat's fair - * args and * * kwargs does feel like a hack, although denoting "zero or more" as * has a bit of tradition. I'd have to disagree with list/dict comprehension, pretty natural considering e.g Javascript/JSON also use [] / {} for each, respectively (Obviously completely subjective). I also get that there's only so many symbols to pick from. Would have been cool if it was *, which is already used for arguments. I think my larger point is that even the small decisions when making a language matter. There isn't really right/wrong or better/worse, but IMO Python operators feel more cohesive/uniform than Ruby or Perl. Also, describing how operator usage feels is hard. Edit: Asterisks causing italics.