So I feel your pain Oliver and I decided to see if I could whip up a bookmarklet (a JavaScript bookmark) that would fulfill the role while the StackOverflow/StackExchange folks debate the worthyness of such a feature ;-)
While I agree that formatting Python code might break things and that StackOverflow might not want to incorporate this to stop seemingly helpful SO users from fixing badly formatted code (when those OP's should learn to write cleaner code)... there are SO users like myself that do post lots of code answers and just want to indent our own code blocks the 4 spaces required by markdown to have the code recognized and thus formatted correctly.
I've posted the raw code up on GitHub: https://github.com/scunliffe/StackOverflowCodeIndent and I'm going to attempt to inline the bookmarklet below:
SORRY, JS based links are blocked on StackExchange sites I've hosted it here for easy access: http://scunliffe.github.io/SOCodeIndent.html
When you are ready to indent your code... highlight your block of code and click the bookmarklet - presto!
Notes:
- It indents every line of the selection with 4 spaces
- It converts any/all leading tabs to 2 spaces
- It does not alter the code in any other way (e.g. adjust bracket whitespace or convert braces to K&R style)
- It isn't currently smart enough to not re-indent if you re-select a block of code that is already 4-space indented