All leading tabs or all leading spaces - why isn't that enforced?
james-netnews at and.org
Tue Aug 7 18:05:16 CEST 2007
On Tue, 07 Aug 2007 02:53:18 +0000, John Nagle wrote:
> One can argue over tab vs. space indentation, but mixing the two is just
> wrong. Why not have CPython report an error if a file has both leading
> tabs and leading spaces? I know that was proposed at some point, but I
> don't think it ever went in. That would catch a common error introduced
> during maintenance.
While I agree it should be default, you can enable extra checking with
% jhexdump /tmp/abcd.py
0x00000000: 2321 202F 7573 722F 6269 6E2F 7079 7468 #! /usr/bin/pyth
0x00000010: 6F6E 202D 7474 0A0A 6966 2054 7275 653A on -tt..if True:
0x00000020: 0A09 7072 696E 7420 2261 220A 2020 2020 ..print "a".
0x00000030: 2020 2020 7072 696E 7420 2262 220A print "b".
File "/tmp/abcd.py", line 5
TabError: inconsistent use of tabs and spaces in indentation
% python /tmp/abcd.py
...note that this doesn't require all spaces or all tabs, just that
their usage has to be consistent.
James Antill -- james at and.org
C String APIs use too much memory? ustr: length, ref count, size and
read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings
More information about the Python-list