As pointed out in the documentation, when tangling Python code, it's important to set org-src-preserve-indentation to a non-nil value. However, tangling still doesn't seem to work correcly: If the first line of a source code block is indented, it ends up dedented to the first column in the resulting .py file.
An example: --8<----8<----8<----8<-- test.org -*- org-src-preserve-indentation: t -*- * Main heading A bit of introduction #+begin_src python :tangle yes class ClassDefinition(IsNotIndented): class_variable = 'is correctly indented' #+end_src #+begin_src python :tangle yes def method_definition(self, is_not_indented_correctly): print 'the method body' print 'is indented correctly' #+end_src --8<----8<----8<----8<-- test.org ends The resulting file after tangling: --8<----8<----8<----8<-- test.py class ClassDefinition(IsNotIndented): class_variable = 'is correctly indented' def method_definition(self, is_not_indented_correctly): print 'the method body' print 'is indented correctly' --8<----8<----8<----8<-- test.py ends Note that the "def method_definition" line should be indented with four spaces. _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode