It's great for beginners. Then it turns into a mess.
- A huge ecosystem of good third-party libraries.
- Named arguments.
- Multiple inheritance.
- It's easy to learn and read. However, it's only easy to learn and read at the start. Once you get past "Hello world" Python can get really ugly and counterintuitive.
- The Pythonic philosophy that "There should be one -- and preferably only one -- obvious way to do it." As someone who loves working within rules and rigid frameworks, I love this philosophy! As someone who writes Python, I really wish Python actually stuck to this philosophy. See below.
- Forced indentation. Some love it because it enforces consistency and a degree of readability. Some hate it because they think it enforces the wrong consistency. To each their own.
- Dynamic typing. There are lots of dynamically-typed languages and lots of statically-typed languages. Which kind of typing is better isn't a Python debate, it's a general programming debate.
-
400 ways (more or less) to interpolate strings. This prints "Hello Robin!" 3 times:
user = {'name': "Robin"} print(f"Hello {user['name']}!") print("Hello {name}!".format(**user)) print("Hello %(name)s!" % user)
If there was a unique and obvious use-case for each of these then that would be one thing, but there's not.
-
69 top-level functions that you have to just memorize. GvR's explanation sounds nice, but in reality it makes things confusing.
-
map
doesn't return a list, even though the whole point of a mapping function is to create one list from another. Instead it returns amap
object, which is pretty much useless since it's missingappend
,reverse
, etc. So, you always have to wrap it inlist()
, or use a list comprehension, which, speaking of... -
List comprehensions are held up as an excellent recent-ish addition to Python. People say they're readable. That's true for simple examples (e.g.
[x**2 for x in range(10)]
) but horribly untrue for slightly more complex examples (e.g.[[row[i] for row in matrix] for i in range(4)]
). I chalk this up to... -
Weird ordering in ternary/one-line expressions. Most languages follow a consistent order where first you declare conditions, then you do stuff based the on those conditions:
if user.isSignedIn then user.greet else error
for user in signedInUsers do user.greet
Python does this in the opposite order:
user.greet if user.isSignedIn else error
[user.greet for user in signedInUsers]
This is fine for simple examples. It's bad for more complex logic because you have to first find the middle of the expression before you can really understand what you're reading.
-
Syntax for tuples. If you write a single-item tuple
(tuple,)
but forget the trailing comma, it's no longer a tuple but an expression. This is a really easy mistake to make. Considering the only difference between tuples and lists is mutability, it would make much more sense to use the same syntax[syntax]
as lists, which does not require a trailing comma, and add afreeze
orimmutable
method. Speaking of... -
There's no way to make
dict
s or complex objects immutable. -
Regular expressions require a lot of boilerplate:
re.compile(r"regex", re.I | re.M)
Compared to JavaScript or Ruby:
/regex/ig
-
The goofy string literal syntaxes:
f''
,u''
,b''
,r''
. -
The many "magic" __double-underscore__ attributes that you just have to memorize.
-
You can't reliably catch all errors and their messages in one statement. Instead you have to use something like
sys.exc_info()[0]
. You shouldn't have a catch-all in production of course, but in development it's very useful, so this unintuitive extra step is annoying.
Most programmers will acknowledge criticisms of their favorite language. Instead, Pythonists will say, "You just don't understand Python."
Most programmers will say a piece of code is bad if it's inefficient or hard to read. Pythonists will say a piece of code is bad if "it isn't Pythonic enough." This is about as helpful as someone saying your taste in music is bad because "it isn't cultured enough."
Pythonists have a bit of a superiority complex.
@AkashicSeer
Maybe you can't. I've never had a problem with it. Different experiences give rise to different preferences.
Try PyCharm Community edition maybe? I even have it set up so I don't have to press a key, it formats when I save.
The point is you don't. The indention is there instantly, and you see instantly if the nesting is correct.
Could this be the issue? You don't use the indention to see if your code is correct?
We don't. We set the nesting of functions, blocks, et cetera. It just "happens" that it also visually formats.
The thing you have to realise is that to other people the indentation is useful. To me and others who like indentation, it is the indention that tells us what the code is. The braces need to be there to satisfy the computer, but to us they're just line noise; the indentation tells us what the code does.
For instance, c:
Looks like both functions are in the if-block to me; and had it been Python I'd be correct and my code would work from the start if I wrote that. But in c, is is incorrect, and one has to reformat for it to be immediately visible.
Worse if you encounter this code in an example. It is obviously wrong, but there is no way of telling what it should do.
Python sidesteps that issue by saying that the for-humans structure is the same as the for-computer structure. Obviously code can still be buggy, but at least it isn't ambiguous and buggy.
Nothing. You still have to tell the IDE how to format. In C you do that with braces, in Python you do it with tab and backspace.
I'm sorry you have problems with Pronterface, maybe you can get a refund? And next time check out the software before you buy it, usually if it's that bad other people will warn you.
...so your apparent hatred of indentation is because you are unhappy with a piece of software you bought? So it's not really about the indentation?
I get that it is unfair, but it not really Pythons fault that you have trouble reading. You don't have a right to demand that everything caters to you, no-one does. Everyone has things that are inaccessible to them. It's not like there is a shortage of other languages you can use instead.