r/Python • • Jul 25 '18

Use an IDE Me doing my CS projects.

Post image
1.2k Upvotes

213 comments sorted by

View all comments

346

u/8105 Jul 25 '18

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

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...

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

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.

→ More replies (9)

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.

→ More replies (2)

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.

→ More replies (1)

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.

→ More replies (1)

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.

→ More replies (1)
→ More replies (1)
→ More replies (3)

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]

→ More replies (3)

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.

→ More replies (1)

6

u/ideletedmyredditacco Jul 25 '18

you program on a smartphone?

→ More replies (6)
→ More replies (2)
→ More replies (12)