News for hackers. Stuff that matters.
Re:“I'm basically giving myself a permanent vacation from be... by patejam on Thursday July 12, 2018 @03:38PM (#17517931)
The indentation should be almost the same as any other language. Unless you have an aversion to consistent code-style.

Python whitespace was only annoying for me years ago when it still had trouble handling tabs and spaces in the same file, and you would run into literally invisible bugs. I haven't run into that in a long time, though.

Re:“I'm basically giving myself a permanent vacation from be... by rabidrat on Thursday July 12, 2018 @03:46PM (#17518007)
It's also basically impossible to cut-and-paste code from a web forum. Was that "else" from the inner or the outer "if"?
Re:“I'm basically giving myself a permanent vacation from be... by gerdesj on Thursday July 12, 2018 @04:11PM (#17518208)
That could be considered a feature. At least you have to read what you have copied and pasted.
Re:“I'm basically giving myself a permanent vacation from be... by rabidrat on Thursday July 12, 2018 @04:34PM (#17518372)
That's cute but I hope no one reading this thinks you are being serious. If they do, to wit:

So many webforums strip leading indents from code. It's not like it looks right on the forum, and then gets inserted into your editor wrong. It's often not right on the source side either. So if you're trying to learn an algorithm from the Python code, you're SOL. This has happened to me.

Re:“I'm basically giving myself a permanent vacation from be... by gerdesj on Thursday July 12, 2018 @08:02PM (#17519602)
It isn't cute at all and I am quite serious. It is an accident that Python syntax pitted against sufficiently unsophisticated code displayers causes copy n paste breakage.

However, that breakage does mean that you have to at least read the code a bit. You either get to avoid a potential security flaw or gain a deeper understanding of an algorithm.

Fixing syntax does not break your ability to learn an algorithm but it will get you closer to its description.

With Python you are generally SIL not SOL.

Re:“I'm basically giving myself a permanent vacation from be... by Retra on Thursday July 12, 2018 @11:47PM (#17520400)
You're not SOL. You just have to retype or reformat the code. Given that you're trying to learn, you should have started with that step anyhow.

I've been writing Python for years and never had this problem.

Re:“I'm basically giving myself a permanent vacation from be... by thedirt0115 on Friday July 13, 2018 @09:31PM (#17528247)
I find this hard to believe. Searching for python copy paste indentation, the first page of results has everything from how to turn it on for various editors to how to turn it OFF for various editors (implying it's built-in to some). If you just gave up 5 seconds after pasting because it didn't look right or work immediately and you didn't even try looking for help... I dunno what to say.
Re:“I'm basically giving myself a permanent vacation from be... by bsg75 on Sunday July 15, 2018 @09:43AM (#17535193)
I would suggest this is more of a forum software problem than a Python problem. Stripping indentation damages the readability of code in any language.
Re:“I'm basically giving myself a permanent vacation from be... by int_19h on Thursday July 12, 2018 @08:44PM (#17519764)
How so? If the code was properly indented on the forum, it'll still be properly indented when you paste it. The only thing you'll need to do is to make sure that indentation of the entire pasted block is consistent with whatever's around it... but pretty much any editor these days, at least the ones meant for code, let you easily adjust indentation of an arbitrary selection (just highlight and Tab or Shift-Tab as needed).
Re:“I'm basically giving myself a permanent vacation from be... by lamontcg on Thursday July 12, 2018 @04:22PM (#17518298)
Also makes auto formatting very difficult when whitespace indentation doesn't just affect readability but syntax.
Re:“I'm basically giving myself a permanent vacation from be... by sametmax on Thursday July 12, 2018 @05:09PM (#17518642)
Use black. It just works.
Re:“I'm basically giving myself a permanent vacation from be... by patejam on Thursday July 12, 2018 @05:47PM (#17518902)
I have problems in a lot of languages copy-pasting code (why are the line numbers being copied!?), but yes this is another problem for this specific language.
Re:“I'm basically giving myself a permanent vacation from be... by acdha on Thursday July 12, 2018 @05:50PM (#17518922)
What editor are you using? This just works in VSCode, vim, TextMate, etc.
Re:“I'm basically giving myself a permanent vacation from be... by Doxin on Friday July 13, 2018 @04:15AM (#17521294)
Make sure you copy the whitespace on the first line as well and then it's just a case of indent/dedenting the whole section of pasted code to match.
Re:“I'm basically giving myself a permanent vacation from be... by LBarret on Monday July 16, 2018 @11:26AM (#17542022)
yes, but that's so minor compared to the gain of a more readable syntax... really an edge case.
Re:“I'm basically giving myself a permanent vacation from be... by gsich on Friday July 13, 2018 @01:26AM (#17520705)
tabs would be much better, but unfortunately pep8 dictates spaces.
Re:“I'm basically giving myself a permanent vacation from be... by zinckiwi on Friday July 13, 2018 @03:18AM (#17521066)
For submissions to the language. For your own stuff, knock yourself out and tab away.