3 ms·
I don't much like it either. Came from C++, learned Perl, got a job writing Fortran, learned Lisp. When hating on Perl came into vogue on the internet, I said
by neutronicus 16y ago
I don't much like it either.
Came from C++, learned Perl, got a job writing Fortran, learned Lisp. When hating on Perl came into vogue on the internet, I said to myself, okay, I will learn Python as a Perl replacement. It is a decent Perl replacement, what with all the libraries and the fact that it is shebang-able.
Now that I've dispensed with background, what I don't like about Python:
1. Assignments don't return values. I hate this. An example. I would like to write:
if (m = re.match("woo, regular expression")):
do some stuff with match object
Instead
m = re.match("woo, regular expression")
if m:
do some stuff with match object
This obscures the fact that I only care about this match object if it evaluates to true.
2. List comprehensions kind of suck. [(a, b) for a in as for b in bs] is a cartesian product and not a zip? Really?
3. Loops don't help this either: There's no equivalent of the Lisp (loop for x in xs for y in ys do (stuff x y)). I have to explicitly loop over the index. This pisses me off.
4. I feel that I am generally shoehorned into creating and assigning more objects than I would like.
Honestly it seems kinda crippled in comparison to Lisp, which, by the way, runs faster.
I would go back to Perl if multidimensional arrays were not so godawful. Perhaps I should try Ruby.
- eru 16y agoPerhaps `zip' could help address some of your points? > 2. List comprehensions kind of suck. [(a, b) for a in as for b in bs] is a cartesian product and not a zip? Really? Strange. I would say it sucked if it was the other way round. You can use the `zip' function, if you want a zip. zip (as, bs) > 3. Loops don't help this either: There's no equivalent of the Lisp (loop for x in xs for y in ys do (stuff x y)). I have to explicitly loop over the index. This pisses me off. Try the function `enumerate' and `zip'. E.g. for x,y in zip(xs, ys): stuff (x,y) If you need an explicit index for your stuff: for (i, (x,y)) in zip(xs, ys): stuff (x,y) > 4. I feel that I am generally shoehorned into creating and assigning more objects than I would like. I agree, only the other way around. Python is much too destructive and relies on in-place updating. E.g. recently we got `sorted' that doesn't sort in-place but return a sorted array --- but the `shuffle' function still works only in-place. Also dicts are destructive. There should be a persistent (i.e. non-ephemeral) data structure for key-value-mappings in the standard library.