From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: Tangling python code results in mixed tabs and spaces, incomaptible with python3 [9.1.4 (9.1.4-dist @ /home/ehere/emacs-scripts/org-9.1.4/lisp/)] Date: Thu, 21 Dec 2017 14:56:04 +0100 Message-ID: <873744kwwb.fsf@nicolasgoaziou.fr> References: <20171220182448.6ltm4m4emmt7ftxv@knuspertop> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS1KT-0003W7-FR for emacs-orgmode@gnu.org; Thu, 21 Dec 2017 08:56:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS1KS-0003zN-I2 for emacs-orgmode@gnu.org; Thu, 21 Dec 2017 08:56:09 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:59593) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS1KS-0003yA-C8 for emacs-orgmode@gnu.org; Thu, 21 Dec 2017 08:56:08 -0500 In-Reply-To: <20171220182448.6ltm4m4emmt7ftxv@knuspertop> (Edmund Christian Herenz's message of "Wed, 20 Dec 2017 19:24:48 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Edmund Christian Herenz Cc: emacs-orgmode@gnu.org Hello, Edmund Christian Herenz writes: > The following python code uses only whitespaces for the different > indentdation levels: > > a_list = ['elem1', > 'elem2', > 'elem3'] > > for elem in a_list: > print(elem) > for char in elem: > print char > > I enter this code into a SRC block with > > #+BEGIN_SRC python :tangle blank_test.py > > #+END_SRC > > by pressing C-' inside the block (which opens the editing buffer > python-mode). Then I press C-' again, after which I tangle the code > to blank_test.py by pressing C-u C-c C-v C-t. The resulting file > blank_test.py will contain a mix of tabs and spaces for the different > intendation levels. (I checked this with whitespace.el). > > Above behaviour is a bug, since Python3 forbids mixing of spaces and > tabs. (Python2 is more relaxed about mixing of tabs and spaces). Thus, > the above code, syntactical correctly entered into an OrgSrc buffer, > will result in code that can not be run in python3 when tangled from > an org-mode file. Have you tried "-i" switch for the block, i.e., #+BEGIN_SRC python -i :tangle blank_test.py Regards, -- Nicolas Goaziou