r/ProgrammerHumor • • Jul 20 '18

Every Time

Post image
52.2k Upvotes

749 comments sorted by

View all comments

2.0k

u/Daposto Jul 20 '18 edited Jul 20 '18

Let's remove some enters and spaces in the code to make it cleaner and run it again, did it often haha.

949

u/Docaroo Jul 20 '18

It's like the compiler doesn't approve of your shitty-ass looking code formatting and doesn't take you seriously.

Clean it up and make it pretty and it believes your code is more credible now!

509

u/WorstGabeNA Jul 20 '18

Some call it python.

0

u/[deleted] Jul 20 '18

[deleted]

128

u/mpa92643 Jul 20 '18

Python is wonderful, but the lack of static typing drives me crazy sometimes (which is why I fell in love with Kotlin: best of both worlds). It's almost never a problem, but when the IDE can't tell me, "yup, that's definitely a string, here are all the things you can do with it" and instead tells me "yup, that's definitely some kind of object. Here's a list of functions you've used on it before, including your typo-ed ones, just try something and you'll find out if it actually works at runtime."

3

u/anders987 Jul 20 '18

That depends on which IDE you use. Visual Studio Code knows that it's a string.

1

u/mpa92643 Jul 20 '18

In situations like that where it's defined as a literal, most IDEs can offer completions, but define it as the result of some custom computational function that always returns a string (or some other object) and the IDE has no clue what it is.

1

u/anders987 Jul 20 '18

Some IDEs still know what it is. Works pretty well.

You can read more about it here: https://blogs.msdn.microsoft.com/pythonengineering/2018/07/18/introducing-the-python-language-server/

Our Python Language Server uses iterative full-program analysis to track the types of all the variables in your project while simulating execution of all the code in your project.

You can also use type hints, should work for most IDEs.

→ More replies (2)