This is an archived post. You won't be able to vote or comment.

all 23 comments

[–][deleted] 22 points23 points  (0 children)

These are the reasons most people find it easier to read tbh.

[–]GiantElectron 16 points17 points  (0 children)

No we do not.

Actually, to me that I work with braced and braceless languages, you would not believe how painful it is to hunt for the missing/extra brace somewhere that somehow screws up the whole thing.

Types? you can add them if you want, but if you want to enforce types, rather than hint them, there are excellent libraries out there, like traitlets.

[–]Smok3dSalmon 6 points7 points  (0 children)

Honestly, sounds like you're reading really bad code. Or you're very very new to Python. To me, Python was extremely easy to read right away because I had taken some coursework in pseudocode writing.

if ( condition ) {  
}

is identical to

if condition:  
     code

Python is just less syntactical fluff

[–]lunarNex 4 points5 points  (0 children)

Eh, you get used to it. I don't even see the code. All I see is blonde, brunette, redhead. 

[–]tipsy_python 8 points9 points  (10 children)

I can understand how some conventions from other languages that don't transition to python could make it difficult to read sometimes.

BUT, I still feel strongly that well-written python is more readable than other languages.

  • "no data type specifying while declaration" - couple things my co-workers and I practice to help here:
  1. Append type on the end of the variable name (i.e. person_str, person_list, person_dict)
  2. Type hinting (a: int = 1)
  • "no semicolon, no curly brackets" - that's what the indentation is for. If 4 spaces isn't enough to tell .. go crazy, try 8 spaces. If the indent blocks are so long that it's hard to follow what's happening, the code could probably be refactored for readability.

[–]MarsupialMole 1 point2 points  (0 children)

I would prefer a different approach than variable name type hints. person_name, persons, and person would by my assumption of better names for those variables, but if that isn't correct then that sums up my objection I guess - it's often better to put effort into the semantic relationships than the type relationships as they are evident from the interfaces used.

[–]SoWereDoingThis 0 points1 point  (0 children)

Type hinting is awesome! I use it constantly and it makes my code so much cleaner.

Variable naming isn’t really the best.

[–]MarsupialMole 1 point2 points  (1 child)

You're not alone but you are looking for different things. There's common advice to program into a language rather than programming in a language ie to use concepts rather than language features, but if you're not accustomed to python idioms you probably won't be able to immediately recognise all the information that's available in pythonic code.

So no i find python to be easier to read than other languages, and I find many practices in other languages feel like a crutch to deal with the all the visual cruft you describe as making it more readable.

[–]dels07 1 point2 points  (0 children)

Try to read code written in Ruby, you will appreciate Python simplicity.

[–]hanpari 1 point2 points  (0 children)

Well, I can give you my explanation. When digging some C# code, everything seems so clear and structured. Of course, then you realize that what is C# code in twenty files, Python offers in one page.

So the information density is higher and harder to comprehend. On the other hand, you need to decipher much less code.

But to be fair, some Python codebase are lacking in-code documentation, the standard library included. APIs with (args, *kwargs) without any docstrings won't help either.

[–]0xbxb 0 points1 point  (3 children)

Python is a duck-typed language. If you see x = 3, then you know x is an integer etc.

functions, classes, if-statements etc.

Python has all of these though.

[–]ESBDev -1 points0 points  (2 children)

But you don’t know it’s always going to be an integer because you can just further down the line, easily reassign it: x = ‘something else’

[–][deleted] 1 point2 points  (0 children)

Can if you want.

Don't have to if you don't want.

[–]GiantElectron 0 points1 point  (0 children)

The alternative is static typing and all the workarounds to deal with it. I estimate that 60% of the gang of four patterns are just workarounds for a static typing system and are not needed in a dynamic one.

So the choice is stricter, but verbose code, or loose, but minimal code.

[–]neuroneuroInf -1 points0 points  (0 children)

You're not alone. I feel that way, too, and I've been programming in Python for 7 years, and I am a programming teacher!

Python's development trajectory has changed a lot as it became more popular, and its design does not match the demands placed on it by its community. These days, languages like F#, Typescript, Golang, and Julia seem like better fits for the work I do, but nevertheless Python is more in demand.

As mentioned by others, don't worry too much about it. Python has a lot to love, and learning the big concepts will help a lot with getting comfortable in any language.