F
3

Just saw a friend's code and they keep putting semicolons in Python

They came from learning JavaScript first and kept adding them out of habit. It doesn't break Python, but it's not the standard style and can look messy to other people reading the code. I found a style guide from the Python Software Foundation that says to avoid them. How do you break a habit like that from a different language?
3 comments

Log in to join the discussion

Log In
3 Comments
maxf33
maxf3314d ago
Honestly, I'd just run a linter on save. It'll flag the semicolons and you'll unlearn it fast.
7
ben_lewis
ben_lewis14d agoMost Upvoted
Forget the linter, just delete them as you type. Your brain adapts way faster when your hands feel the mistake. I tried the linter route and it just made me ignore warnings after a while. Actually backspacing over each one builds the muscle memory. Took me about a week of writing new code before the urge to type a semicolon just stopped.
4
wendy820
wendy82013d ago
Backspacing over every semicolon sounds like a special kind of coding torture (but maybe the painful kind that works). My linter warnings just become invisible wallpaper after two days, so I see the logic. A week of that and your fingers would probably revolt and start typing Python instead.
4