On Fri, Dec 5, 2014 at 10:40 AM, Aahan Krish <kr...@aahan.me> wrote:
> Q2. PEP 8 also reads, "Python 3 disallows mixing the use of tabs and
spaces for indentation."
>
> So, if I am using tabs for indentation and spaces for alignment, is it
still considered "mixing the use of tabs and spaces" in Python 3? (Please
see this example.)

No, you can mix tabs and spaces as long as you do so consistently within a
block, i.e. if one line is indented with <tab><sp><sp><tab> then the next
line in the same block had better start with that same exact sequence. The
difference is that Python 2 when trying to compare indentation will treat a
tab as equal to 8 spaces (or was it 4?) which can lead to situations where
the relative indentation of two lines looks one way to the programmer but
is lexed a different way by the interpreter. Python 3 resists the
temptation to guess in this situation and simply raises an error.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to