I hate you all

Isaac To isaac.to at gmail.com
Fri Apr 5 18:35:42 EDT 2013


You underestimated the arrogance of Python.  Python 3 tab doesn't map to 4
spaces.  It doesn't map to any number of spaces.  Tabs and spaces are
completely unrelated.  If you have a function having the first indentation
level with 4 (or any number of) spaces, the next line starting not with 4
spaces but instead with a tab always lead you to the TabError exception.

If you like to play tricks, you can use "4 spaces plus a tab" as the next
indentation level.  I'd rather not do this kind of things, and forget about
use using tabs at all.  You are out of luck if you want to play the
tab-space tricks, but if you follow the lead, you'll soon find that code
will be more reliable without tabs, especially if you cut-and-paste code of
others.


On Sat, Apr 6, 2013 at 6:04 AM, <terminatorul at gmail.com> wrote:

> On Saturday, April 6, 2013 12:55:29 AM UTC+3, John Gordon wrote:
> > In <64d4fb7c-6a75-4b5f-b5c8-06a4b2b5d0cb at googlegroups.com>
> terminatorul at gmail.com writes:
> >
> > > How can python authors be so arrogant to impose their tabs and spaces
> > > options on me ? It should be my choice if I want to use tabs or not !
> >
> > You are free to use tabs, but you must be consistent.  You can't mix
> > tabs and spaces for lines of code at the same indentation level.
>
> They say so, but python does not work that way. This is a simple script:
>
> from unittest import TestCase
>
> class SvnExternalCmdTests(TestCase) :
>     def test_parse_svn_external(self) :
>         for sample_external in sample_svn_externals :
>             self.assertEqual(parse_svn_externals(sample_external[0][0],
> sample_external[0][1]), [ sample_external[1] ])
>
> And at the `for` statement at line 5 I get:
>
> C:\Documents and Settings\Adrian\Projects>python sample-py3.py
>   File "sample-py3.py", line 5
>     for sample_external in sample_svn_externals :
>                                                 ^
> TabError: inconsistent use of tabs and spaces in indentation
>
>
> Line 5 is the only line in the file that starts at col 9 (after a tab).
> Being the only line in the file with that indent level, how can it be
> inconsistent ?
>
> You can try the script as it is, and see python 3.3 will not run it
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130406/17538109/attachment.html>


More information about the Python-list mailing list