r/Python • • Jul 25 '18

Use an IDE Me doing my CS projects.

Post image
1.2k Upvotes

213 comments sorted by

346

u/8105 Jul 25 '18

Use a good editor/IDE. No more indentation errors.

9

u/RealHugeJackman Jul 25 '18

Screw that, just type in spaces manually and count out loud

14

u/vortexofdeduction Jul 25 '18

Agreed. If you use a good IDE, you’ll catch all the basic stuff before you even hit run, and it will be easy to indent correctly. (I like Pycharm, but there are lots of good options out there)

7

u/jsalsman Jul 25 '18

I don't know. If OP is running into indentation errors enough to complain about them in coursework, I'd suggest refactoring into function calls over getting an IDE. IDEs can't solve all indentation bugs, and the kind of bugs that beginners make are different.

6

u/TheNamelessKing Jul 25 '18

Turnings things into functions will 100% help, but I’ve not found an indentation error that Pycharm has failed to fix.

0

u/redalastor Jul 25 '18

However braces nesting problems in other languages... ouch.

0

u/mindfolded Jul 25 '18

I like Pycharm. I use it a lot. It's decent, but it does some odd stuff with the vim plugin installed. Anytime I do a column select and insert text (ctr-v, shift-i, <insert text>, escape) the cursor jumps up 50 lines and all my closed folds open back up.

3

u/Saiboo Jul 25 '18

Can you elaborate on using functions to avoid indendation errors? Thank you!

5

u/inFenceOfFigment Jul 26 '18

Imagine you write a script that requires 5 levels of indentation. Now you refactor, and decide to put everything that was in the 3rd level of indentation, and beyond, into its own function. This function is defined at the top level of your script. Now you have one helper function, containing 3 indents, and a main with a call to that helper, only 2 indents. Thus, pulling code out to a function reduced the overall max indentation in your script.

In general, code should be put into functions for reasons other than indent level, but if you find yourself indenting excessively it's a sign that the code may be due for a refactor.

1

u/Saiboo Jul 26 '18

Thank you so much for your explanation, much appreciated!

2

u/jsalsman Jul 29 '18 edited Jul 29 '18

Sure.

def messy():
    if booleanA:
        if booleanB:
            doA()
        else:
            doB()
    else:
        doC()

can be refactored into

def subroutine():
    if booleanB:
        doA()
    else:
        doB()

def neat():
    if booleanA:
        subroutine()
    else:
        doC()

2

u/Saiboo Jul 29 '18

Thank you so much for the code example, much appreciated!

2

u/jsalsman Jul 29 '18

No problem. I edited it to put the subroutine definition before its call, which isn't always necessary depending on whether the source file is parsed before neat() gets called, but is almost always more readable with real production code.

2

u/mooburger resembles an abstract syntax tree Jul 25 '18

I agree. "Good" IDEs is what made bad Java stay bad Java. "Oh, self documenting classes, LetsCallOurClassWithSelfDocumentingNameReference ({});". So now it's going to autocomplete for you and you never question the pattern.

1

u/jsalsman Jul 25 '18

When do the educators branch from the guild mentality hoarding knowledge?

0

u/vortexofdeduction Jul 25 '18

IDE’s don’t automatically fix errors, but they give the user immediate feedback as they time rather than having to run the code and find out it doesn’t work. And they do a lot more than just report indentation errors.

Also, Pycharm gives the line the appropriate indentation when you hit newline, which is more than some simple text editors would do.

1

u/astutesnoot Jul 25 '18

PyCharm and all the other JetBrains IDEs are also free for students.

4

u/vortexofdeduction Jul 25 '18

Isn’t the Community Edition of Pycharm free even if you aren’t a student?

13

u/EnfantTragic Jul 25 '18

I haven't seen an indentation error in forever. What are people using?

0

u/[deleted] Jul 26 '18

[deleted]

1

u/IReallySuckAtChess Jul 26 '18

Tab set to four spaces and be done with it. I've seen too many people use space bar for indenting.

0

u/flying-sheep Jul 26 '18

*deep breath* tab set to tab.

seriously, use black. I love tabs and single quoted strings, but it frees you from thinking about useless things like that

1

u/IReallySuckAtChess Jul 26 '18

I can't believe you're getting down voted? Whilst I strongly disagree with your practices, you should be free to do what you please.

I don't use black, but I've heard great things about it. I just let pycharm refractor and reformat my code to pep8 standards.

2

u/Plungerdz Jul 25 '18

Agreed, but you probably don't know how much indentation matters on mobile IDEs. It makes code supremely cumbersome to copy paste (since, for some reason, at least in my IDE, a copied function definition reindents itself into an abomination). It's just a train wreck when you don't really have the luxury to use a legit IDE.

45

u/NotABothanSpy Jul 25 '18

Who the fuck uses mobile ide

9

u/crescentroon Jul 25 '18

I just googled for mobile IDE. I found lots of sites with random lists of the "5 best mobile IDEs" but no-one could explain why they get used.

1

u/Plungerdz Jul 25 '18

Well, just because they're in the top five doesn't mean they solve indentation hassles for you.

6

u/ideletedmyredditacco Jul 25 '18

you program on a smartphone?

1

u/Plungerdz Jul 25 '18

Not exclusively, but I also code on a smartphone, yes.

8

u/Log2 Jul 25 '18

Serious question: why?

2

u/astutesnoot Jul 25 '18

Probably because they haven't decided is CS is the major they're sticking with, and they don't want to invest in proper hardware until they decide. I've heard that excuse before. Of course, those are generally the people who drop out.

1

u/El-Kurto Jul 25 '18

Imma go with "because I have it with me"

0

u/[deleted] Jul 26 '18

[deleted]

1

u/crunk Jul 26 '18

Termux is cool ... but I wouldn't say it's easy...

*lots* of things work on termux, but enough don't that it gets slightly weird. And typing is painful whatever keyboard you use.

10

u/falsemyrm Jul 25 '18 edited Mar 12 '24

deliver swim friendly kiss repeat cause squeeze shaggy imagine encouraging

This post was mass deleted and anonymized with Redact

-1

u/dadinvancouver Jul 25 '18

I find that Pycharm often has difficulty auto-intending my code correctly.

Imo, significant white space is the biggest negative about Python overall.

1

u/namesnonames Jul 25 '18

I don't usually have any problems with pycharm indentation, could you give an example? Also I think that significant whitespace is amazing. I've seen so much terribly indented code in other languages that I enjoy the piece of mind that at least there is some enforced structure.

1

u/dadinvancouver Jul 25 '18

Can’t say I’m batting very high. I’ll highlight a block of code and it often won’t indent it correctly so I end up cursing significant white space while I fix it.

1

u/chason Jul 26 '18

out of curiousity, what do you mean you "highlight a block of code and it often won't indent it correctly"? I'm trying to understand your issue since I can't recall ever having an issue with whitespace in Python.

1

u/dadinvancouver Jul 26 '18

I'm not at my development machine at the moment, but unless I misunderstand the way the auto-indent feature works in Pycharm, you must select the code you want auto-intended first.

Sometimes I'll copy and paste from one part of my application to another and so the indenting is off.

I'm anal retentive, so I always fix the indenting anyways. Sometimes you just want to see what happens with your hacked code though and worry about indenting later.

2

u/crunk Jul 26 '18

If the start and end are indented differently, then things tend to go wrong when you paste, I guess because there isn't really a correct answer there, though they could probably do better.

1

u/IReallySuckAtChess Jul 26 '18

Dude you're using it wrong. Pycharm will even fix poor indentation when pasting from another source as well as smart pasting in general. Let's not forget that reformatting the entire document to be pep8 compliant is like three key strokes or a single button in the menu.

0

u/[deleted] Jul 25 '18

[deleted]

47

u/[deleted] Jul 25 '18

I can confirm, I have to use notepad to fix bugs on a remote windows server 2003 that is only accessible trough citrix, since there's no way to copy the files locally since the clipboard copy or remote transfer isn't allowed.

It's pure hell.

13

u/mezbot Jul 25 '18

Why not use a web IDE in that scenario?

14

u/ies7 Jul 25 '18

I have encountered similar scenario plus added bonus where the server isn't connected to the internet.

Funny thing is it just need a simple proxy pointed to my computer to solve the internet access

10

u/trowawayatwork Jul 25 '18

you could try this if you wanted to look cool

8

u/hackersaq Jul 25 '18

A certain type of woman does dig a man in prison stripes...

1

u/[deleted] Jul 25 '18

It would be necessary to install a web server + php or whatever o a windows server 2003.... Which is also strictly closed due security reasons, so it's not an option, probably the company will migrate to Linux, but it's not currently planned.

2

u/marcosdumay Jul 25 '18

Why would you need a web server to get an IDE (or text editor) running?

5

u/captain_awesomesauce Jul 25 '18

He's replying to the advice to use a web IDE.

1

u/ianepperson Jul 25 '18

He's not saying to install anything. As long as the machine can browse the web you can remote access to it and use its browser as an IDE. Check out https://codeanywhere.com

6

u/[deleted] Jul 25 '18

Sadly it's on a network that is completely isolated :\

Only way to do anything there is via notepad ( it doesn't even have idle to be used. )

1

u/PM_ME_YOURSELF_AGAIN Jul 25 '18

What's citrix?

4

u/[deleted] Jul 25 '18

Platform for desktop/application virtualization =)

0

u/[deleted] Jul 25 '18

[deleted]

2

u/[deleted] Jul 26 '18

I can see a lot of use cases for this, but sadly it would not solve my problem.... Since there's no way i could upload or send the files back to the server after some aditional development.

8

u/Folf_IRL Jul 25 '18

Hell, you can even set up Vim to do it for you. So you don't even need an IDE.

-9

u/NotABothanSpy Jul 25 '18

Or just get some fucking glasses

10

u/13steinj Jul 25 '18

Tell that to people who have visual impairments that can't be fixed so easily.

I mean, yeah, me personally, I couldn't give a shit about the whole whitespace thing. But I know people with visual impairments for which it is the bane of their existence, because they are much more used to just dropping a braces based scope in and then using their IDE to automatically indent the file.

→ More replies (4)

0

u/NightflowerFade Jul 25 '18

I used pastebin for an entire project in first year

0

u/[deleted] Jul 25 '18

[deleted]

1

u/ed_elliott_ Jul 25 '18

Notepad and grep.com :)

0

u/[deleted] Jul 25 '18

[deleted]

4

u/mindfolded Jul 25 '18

Unless you argue that vi is an IDE, I can code quite happily without one. However for very large projects, gotta love an IDE and its auto-completing.

2

u/IReallySuckAtChess Jul 26 '18

Dude, move to vim. Joke aside, vim can have absolutely fantastic auto-complete. Don't underestimate it. Vim makes a great working environment... And then there is emacs.... Emacs....

33

u/[deleted] Jul 25 '18

It can fit so many imported libraries.

4

u/[deleted] Jul 25 '18

Sounds like any Javascript project.

3

u/Alar44 Jul 25 '18

This is what I was expecting.

3

u/[deleted] Jul 25 '18

Unexpected expectations error

47

u/haragoshi Jul 25 '18 edited Jul 25 '18

Slaps roof of programmers head This bad boy can fit so much lack of common sense in it!

Seriously bro, who has indentation errors? Any reasonable person will use the right tool for the job. You have so many options with Python 🐍!

Edit: Here are some options:

Pycharm (my favorite).
IDLE (comes with standard distributions).
Jupyter Notebook (comes with Anaconda).
Spyder (has some neat debugging tools).
Atom (cross platform, cross language open source text editor).

10

u/Zouden Jul 25 '18

OMG there's a python emoji 🐍🐍🐍

6

u/crescentroon Jul 25 '18

OMG there's a python emoji 🐍🐍🐍

And it looks like a '2'

15

u/EJOtter Jul 25 '18

Still using python 2 in 2018 smh

2

u/ivosaurus pip'ing it up Jul 25 '18 edited Jul 26 '18

Looks like a 3 fallen over backwards, to me

Or if I stop trying to see only numbers, a w

5

u/BradyLR Jul 25 '18

Atom is the bomb. ⚛️

0

u/JeusyLeusy Jul 25 '18

Nuclear bomb*

1

u/jcotton42 Jul 26 '18

You forgot VSCode

0

u/[deleted] Jul 26 '18

wut? this is obviously r/ProgrammerHumor material. I mean the only reason one would have indentation errors if they went across IDEs with different indentation formats.

41

u/hobo_cuisine Jul 25 '18

Copy/pasting much?

60

u/gradient_x Jul 25 '18

Pycharm

0

u/[deleted] Jul 25 '18

[deleted]

3

u/faceplanted Jul 25 '18

On my laptop that shortcut doubles as a log dump for the track pad driver and every time you press it it freezes the machine for a couple seconds to do it.

0

u/FuriousPizza Jul 26 '18

What a useful hotkey!

34

u/NavaHo07 Jul 25 '18

Are you coding in notepad? Im pretty certain that about .001% of my errors are indentation errors. Thank you, pycharm

21

u/SirCarboy Jul 25 '18

I remember starting out with python, seeing all the hate over tabs/spaces, and thinking, "You guys are programmers, right? You're, like, supposed to be good at computers and stuff?"

10

u/[deleted] Jul 25 '18

Are you working in MS Word?

28

u/Sohcahtoa82 Jul 25 '18

If you're having indentation errors, then either you're using a really bad text editor, you're copy/pasting code from web sites (You don't learn much from this, imo), or you're failing to grasp what indentation means and are just plain doing it wrong.

In any case, those problems go away with just a modicum of experience.

1

u/gabzox Jul 25 '18

I found it easier to pick up indentation then the other codes format. But to each their own

0

u/Imakesensealot Jul 26 '18

If you found that easier than curly braces then I'm not sure what kind of a creature you are.

1

u/gabzox Jul 26 '18

Im a normal person..even when codding with curly braces you should be indenting...also dont forget the ";".

9

u/[deleted] Jul 25 '18

Use VSCode with Anaconda and you will never have to worry about it again :D

4

u/[deleted] Jul 25 '18

this is not a problem you need to have

4

u/thisusernameismeta Jul 25 '18

Serious advice time:

If you have a good computer to code on, download PyCharm and use that. Since you're a student, you can get the Professional edition. Use PyCharm for bigger projects- ones that have more than a few files, more than a few classes. However, for smaller things, if you don't want to wait the 10 minutes for it to boot up...

Download Sublime or Atom (your call, I use Sublime but have heard Atom is great too). This is just (just?!?) a simple text editor, but has syntax highlighting for just about any language.

On the bottom bar of the window, you can set indentation for tabs or for spaces. If you choose spaces, the editor will insert 4 (or whatever other number it's set to... Choose 4 for python ) spaces every time you press the tab key.

PyCharm should convert your file automatically, but as a student, a good text editor should be plenty good enough for all your needs. I didn't need to start using an IDE until after I graduated and started working.

Sublime/Atom should have ways to convert your whitespace back and forth between tabs and spaces. Choose one and stick to it.

You shouldn't be getting so many indentation errors once you choose a standard for yourself and stick to it.

Good luck!

4

u/JeusyLeusy Jul 25 '18

If you are poor on resources you can use vim and try out some plugins.

0

u/astutesnoot Jul 25 '18

And if you have a slow computer as a student, you can try getting your free Azure student credits and running a Windows VM on Azure for your dev tools.

1

u/DelScipio Jul 26 '18

Try Visual code. It's like sublime but better.

I used sublime for years then tried Visual code and never used sublime again. Everything is more organized, works almost out of the box. Give it a try someday.

4

u/vitogeek Jul 25 '18

Been using python for years, never ever had this issue.

Just use an IDE. Indentation is not supposed to be the hard part of programming.

3

u/[deleted] Jul 25 '18

This is why we have Pycharm people

3

u/shponglespore Jul 25 '18

What a strange thing to say. To me, an "indentation error" is when the indentation doesn't match the semantics of the program. Python is just about the only language that doesn't have indentation errors, because the compiler won't allow it.

1

u/[deleted] Jul 29 '18

because the compiler won't allow it.

...and will proceed to raise an IndentationError.

5

u/ck35 Jul 25 '18

Use python 3 -- Any indent inconsistency is an error.

2

u/red_keshik Jul 25 '18

What's the issue with braces anyway ?

1

u/silon Jul 25 '18

In python they are more verbose:

{ is :
} is pass

1

u/kennydude Jul 26 '18

It doesn't make anything better for CS students. They'll just throw braces everywhere and complain their code doesn't work.

2

u/IonTichy Jul 25 '18

Is no subreddit safe from this shitty image macro?

2

u/jabalfour Jul 26 '18

Amazed at the number of Pycharm devotees that come out of the woodwork when editors/tooling gets brought up. I like it fine - a little slow perhaps, but I work for the government so every laptop is slow.

I will say - and please keep in mind that I’ve hated everything M$FT since elementary school - VS Code is getting damned good. Robust community, tons of extensions (I think it poached most of Sublime’s PackageControl.io); including many useful Python ones.

The best extension, though, and the most germane for the this question: Black. It’ll solve your indentation problem very quickly. And many others you don’t even realize yet.

2

u/crunk Jul 26 '18

First time you open a new editor, find the tab/spaces setting and set tab to input 4 spaces.

2

u/kennydude Jul 26 '18

Learn to indent properly.

I seriouslty hated other CS students in the middle of the screen with identation, and code just everywhere, and then wondering why their code didn't work with the stupid excuse of "oh but i can just get the editor to fix it for me".

The fact Python forces you to pick up this good habbit is a really good thing.

2

u/derp0815 Jul 25 '18

Well at least you can mangle a dead meme.

2

u/589ca35e1590b Jul 25 '18

Pay more attention.

-2

u/mbillion Jul 26 '18

Imo, it's kind of pointless to a degree. Something shouldn't just not work because of spacing. It causes me a fair bit of frustration at times and I'm pretty seasoned

1

u/589ca35e1590b Jul 26 '18

Python was designed to be readable so it kinda makes sense

1

u/mbillion Jul 26 '18

Not arguing at all... Just saying four space indents don't make code much more readable... I've seen ugly Python too... So is it worth it

1

u/Pr0ducer Jul 25 '18

I'll bet you use both tabs and spaces too.

Sublime Text. Any .py files will auto indent when you hit return, and there's plenty of linter extension to highlight any syntax errors.

1

u/Raymi Jul 25 '18

configure your environment to input the appropriate number of spaces when you press tab. find and replace all tabs after zero or more spaces at the beginning of a line with the appropriate number of spaces every time you open a file someone else has touched. try to get each function and method down to a size where it can be displayed on your monitor all at once (a vertical monitor helps with this).

1

u/Thecrawsome Jul 25 '18

Can fit so many hello worlds in it

1

u/PythonGod123 Jul 25 '18

What do you code on. Notepad++?

1

u/here-to-jerk-off Jul 25 '18

Better joke would have been threads

1

u/Tankerspam Jul 25 '18

Relatable

1

u/[deleted] Jul 26 '18

Indentation errors are a non-issue. Y u no code good?

1

u/beecushman Jul 26 '18

Just YAPF and move on with your life.

1

u/doulos05 Jul 26 '18

I've had indentations problems in Python files twice, both times were my fault, and both times, my ide caught them.

The first time was when I decided I only needed 2 spaces worth of indentation so I could nest more deeply. Then I had to change all my code from 4 to 2 (that vim script too my like 5 minutes to figure out cuz I was new).

The second time was when I learned to refactor and went back to 4 spaces so I'd be in line with common style. That time, the vim script took slightly longer because it kept infinitely recursing. Neither time led to an actual indentation error being thrown by the interpreter because the interpreter never saw the code.

1

u/[deleted] Jul 26 '18

/u/Trollabot DeadLantern-

1

u/hoppi_ Aug 05 '18

Lmao this is so hilarious :D

1

u/[deleted] Jul 25 '18

I used to work across 2 machines; a laptop running Linux and a desktop machine running Win7 and before I switched to (the pythonic and PEP 8 recommended) 4 spaces I would run into endless headaches because the 2 OSs don't interpret tabs the same.

1

u/[deleted] Jul 25 '18 edited Jul 25 '18

White space sensitive languages suck ass. Fuck yaml too

2

u/[deleted] Jul 26 '18

Yaml is trash, agree.

1

u/[deleted] Jul 25 '18

I've never found this to be a challenge, so I don't quite understand why it's hard for others. Could someone perhaps explain to me why? I'm not being accusatory, I just don't understand why managing whitespacing is hard.

1

u/mbillion Jul 26 '18

Is python your first or forest really hard language.

Most other languages don't have such an emphasis or no emphasis at all on spacing conventions. So for me it's challenging because I learned Python after learning languages where spacing wouldn't blow you up

1

u/[deleted] Jul 26 '18 edited Jul 26 '18

I played with old Javascript, then learned Java first, then Python, then revisited Javascript (es6 and higher). I'm entirely self-taught (a side from cs50 and internet resources). My Java code was always well-indented and -spaced because it helps me read what I wrote. I always viewed making the code readable and consistent as a primary part of programming.

Edit: make an implication more explicit

Edit 2: have a rescue upvote because I think your point is valid about suddenly-imposed constraints and the shock that can occur because of it

2

u/mbillion Jul 26 '18

I mean I know readable code is important, but I would at least in part argue that comments are for more issue than spacing conventions. I can clean a lot more high level from comments than I can from just reading through lines of code

1

u/[deleted] Jul 26 '18

I'm not sure where comments fit into this (do doc strings also count?). For me, they sit at the same indentation as the code block it describes. My comments discuss why I chose to do something or a one-liner for large, important but obvious code blocks. I also sometimes use them to section out blocks as a brief summary for easy quick scrolling. It sounds like managing comments can also be a challenge when learning.

0

u/mooburger resembles an abstract syntax tree Jul 25 '18

lrn2spacebar, it's really not that hard. I mean you're posting on Reddit. Code in markdown is basically hit the spacebar 4 times. Further indentation is just multiple of that. tap-tap-tap-tap, tap-tap-tap-tap. How hard can that be. Indentation is to force you to write clean, legible code. If you've got code where you've lost track of indentation, you probably need to refactor.

-10

u/GreatSnowman Jul 25 '18 edited Jul 25 '18

But your arent a Python Developer if you haven't had atleast one indentation error an hour.

Or that might just be me...

edit: Wow, i guess people don't like my humor

22

u/NotABothanSpy Jul 25 '18

I don’t think I’ve had one in years

0

u/[deleted] Jul 25 '18

[deleted]

1

u/NotABothanSpy Jul 25 '18

Yes maybe too many meetings I guess

-1

u/luke_c Jul 25 '18

Do people actually prefer indentation over brackets? Whenever I use Python I always find myself wishing I had indentation as it's just so much clearer for me to read.

-1

u/mbillion Jul 26 '18

Seriously my biggest frustration with Python

-35

u/0xSpock Jul 25 '18 edited Jul 25 '18

Yeah. Worst decision made in python. It can kick you from surprise when you need to edit some file remotely having some basic editor like nano, vi(not vim). A specially when someone before you mixed spaces with tabs few years earlier when marking some minor change in different editor. In 1kLOC file. Another problem is that it is hard to make great formatting tools for python fixing wrong indentations. One tab more and your line is inside for loop and tool can’t figure out is suppose to be there or out of loop. What is wrong with {}, begin/end is beyond my understanding :-) Beside that it’s lovely general purpose language.

10

u/saulmessedupman Mmmm spam Jul 25 '18

Python forces readable code

2

u/mbillion Jul 26 '18

Not really, I've seen plenty of very ugly Python code

-1

u/13steinj Jul 25 '18

This not only doesn't force readability (I can use indentation very, very disgustingly), but also hurts those with visual impairments.

2

u/saulmessedupman Mmmm spam Jul 25 '18

Visual impairments. Give me a break.

1

u/13steinj Jul 25 '18

Tell that to this guy

1

u/saulmessedupman Mmmm spam Jul 25 '18

I have a friend that isn't 100% blind but he's close. he's a developer and I've never heard him complain about indentation. In fact, I've never heard him complain ever; a true inspiration.

2

u/13steinj Jul 25 '18

I didn't know people weren't allowed to suggest braces would be a nice thing to have without people assuming it's a complaint.

1

u/saulmessedupman Mmmm spam Jul 25 '18

Python was designed to use (newline followed by) indentation instead of braces, parenthesis, semicolons, etc. For those that know what happens from code to machine language you know both aren't necessary. I'm sure it's no stretch to say having more than one option is not feasible either. And if you try to tell me other languages use braces and indentation you don't understand what's going on. Not to mention Python has the PEP8 style guide.

2

u/13steinj Jul 26 '18

Adding another option, specifically braces, is simple. There already exists a transpiler from Bython, literally Python with braces, to Python. Now it's just a matter of modifying the actual C parser instead of having it at a higher level.

The Python style guide is irrelevant to the writability of code by people with visual disabilities.

1

u/FloppingNuts Jul 25 '18

get new eyes lmao

1

u/13steinj Jul 25 '18

Tell that to this guy

0

u/[deleted] Jul 25 '18

[deleted]

17

u/aphoenix reticulated Jul 25 '18

very few programmers outside python don’t indent correctly, so this is pointless.

I don't think the downvotes were from python fanboyism, but from that comment being obviously incorrect. If that's what you've experienced, then you're lucky.

→ More replies (12)

10

u/evinrows Jul 25 '18

If you can't write code with proper indentation unless the compiler interpreter forces you to, you're a moron. This feature is pretty damn pointless on Python, but I like other things about Python.

I always wonder why people feel so strongly about this. I agree, it's easy to get indentation right... so what's the problem? Who cares that it requires you to get the indentation right? Your experience won't change at all if you're not screwing it up.

If I had to rank language design decisions in terms of importance, I think whitespace vs curly braces would be one of the last items on the list. It just happens to be one of the simplest topics to understand which makes gives it a low barrier to entry for absurdly passionate stances.

2

u/orokro Jul 26 '18

Thank you.

Only Python coders are so obsessed with indentation. For every other language it's par for the course. Many people replying to me make it seem like Python is a sanctuary of proper indentation, and any code written in other languages is chaos with no indentation at all.

It's not hard at all to get indentation right, and for all the great things about Python, it's strict enforcing of indentation is not one of them.

→ More replies (1)

6

u/hextree Jul 25 '18

very few programmers outside python don’t indent correctly

This is far from true. And there isn't even an established 'correct' indentation pattern, it's a style thing. You can easily have several developers indenting according to different styles.

→ More replies (4)

4

u/saulmessedupman Mmmm spam Jul 25 '18

Lol, python compiler

→ More replies (2)
→ More replies (5)

4

u/crescentroon Jul 25 '18

Tool can't really correct missing braces in C++ either. Although it can detect them more easily in certain circumstances.

0

u/[deleted] Jul 25 '18

[deleted]

1

u/1h8fulkat Jul 25 '18

In use nano...FML

0

u/[deleted] Jul 25 '18

[deleted]

32

u/TrixieMisa Jul 25 '18

tabs (which are clearly superior)

Burn the witch!

1

u/IReallySuckAtChess Jul 26 '18

I use tab... It's just mapped to four spaces or in most IDEs to indent and not actually output \t

0

u/[deleted] Jul 25 '18

[deleted]

17

u/1ynx1ynx Jul 25 '18

According to pep-8, it's spaces.

0

u/[deleted] Jul 25 '18

[deleted]

10

u/mooburger resembles an abstract syntax tree Jul 25 '18

Because for the "1 char" the editor can be configured to show it as how many character spaces it chooses. This makes tabs visually inconsistent. If I open a file in an editor and I suddenly see 2 spaces (that is 1 tab) but in a different editor (or in the terminal; or both (vi, emacs, etc.)) I look at the same file and it's 4 spaces, that violates POLA.

Whereas with spaces you know what indentation level you're at when looking at the code in any visual format, since it's always the same as 4 space widths characters worth of space..

1

u/BillyWasFramed Jul 26 '18

Serious question, why don't we want the developer to have control over the indentation level? Why is it preferable that you get to control the indents on my screen? What if I prefer 2 and you prefer 4?

2

u/TrixieMisa Jul 26 '18

PEP-8 again. 4 spaces.

1

u/BillyWasFramed Jul 26 '18

Does PEP-8 answer the question I just posed?

→ More replies (0)

1

u/mooburger resembles an abstract syntax tree Jul 26 '18

because in the real world, other people than you will probably need to be able to read your code.

1

u/BillyWasFramed Jul 26 '18 edited Jul 26 '18

Oh look, a condescending non-answer. why not use tabs and let me worry about indentation? Are you not answering because there isn't a good answer? If it were really about readability, why wouldn't you use the character that allows me to decide what's readable? You have tabs set to 4? Congrats. You're using 4 spaces. I have tabs set to 2? Congrats, I'm using 2 spaces.

→ More replies (0)

1

u/crunk Jul 26 '18

Because the majority of projects involve more than one developer.

Imagine if spaces and tabs are mixed (which invariably happens if one person uses tabs).

1

u/XtremeGoose f'I only use Py {sys.version[:3]}' Jul 26 '18

Becuse if I've done something pretty where I've alligned function arguments or a dictionary literal:

def f(arg1,
      arg2):
    d = {
         'x': 1,
         'y': 2
        }

And you come along with a different tab width you might see something like this:

def f(arg1,
           arg2):
         d = {
                 'x': 1,
                 'y': 2
                }

Which is easier to read for you?

1

u/BillyWasFramed Jul 27 '18

Yeah this example makes the most sense. You can't just do tabs for indention and spaces for alignment and not end up with code like this. Even if you could, it would be impossible to enforce...

3

u/1ynx1ynx Jul 25 '18

I didn't write that document and I don't know the motives behind that decision (if there were any). It's really a matter of preference. But they did have to settle with one to ensure consistency in the standard library.

13

u/ShredForMe Jul 25 '18

Spaces, but set your IDE to input spaces when you press tab

7

u/-revenant- Jul 25 '18

Ahh, I see you're a man of culture as well.

6

u/localhorst Jul 25 '18

Which one is it?

It’s a religious question that cannot be answered by science or technology.

1

u/Kortike Jul 25 '18

This guy knows what’s up🙄

1

u/bwv549 Jul 26 '18

But just as soon as we decide what it is we value most it becomes an optimization problem with (in this case) a single global maximum. ;)

0

u/Blazerboy65 Jul 25 '18

It's whatever you configure your auto format tool to use. Just pick one and never worry about it

1

u/JeusyLeusy Jul 25 '18

Python design conventions basically say you need spaces instead of tabs. What I do I just use soft tabs and suck it up. Can't imagine myself smashing enter four times in a row every 3 seconds.

0

u/[deleted] Jul 26 '18

[deleted]

1

u/the_asset Jul 26 '18

Some (not all) editors are configurable such that pressing tab enters a configurable number of spaces (rather than an actual tab character)

0

u/[deleted] Jul 25 '18

[deleted]

0

u/[deleted] Jul 25 '18

[deleted]

1

u/OhJaDontChaKnow Jul 26 '18

:set noexpandtab ಠ_ಠ

1

u/Plasma_eel Dec 16 '18

YAML will remember this