"Usability, the Soul of Python"

Chris Rebert clp2 at rebertia.com
Wed Mar 31 01:20:32 CEST 2010

On Tue, Mar 30, 2010 at 3:32 PM, Robert Fendt <no.spam at local.local> wrote:
> And thus spake "Alf P. Steinbach" <alfps at start.no>
> Tue, 30 Mar 2010 13:40:22 +0200:
>> <quote>
>>  From a usability standpoint, the braces go with the lines to print out the
>> stanza rather than the for statement or the code after, so the following is best:
>> for(i = 99; i > 0; ++i)
>>      {
>>      printf("%d slabs of spam in my mail!\n", i);
>>      printf("%d slabs of spam,\n", i);
>>      printf("Send one to abuse and Just Hit Delete,\n");
>>      printf("%d slabs of spam in my mail!\n\n", i + 1);
>>      }
>> </quote>
> I liked this one even more:
> <quote>
> One way of writing the same code in Python would be:
> count = 99
> while count > 0:
>    print u'%d slabs of spam in my mail!' % count
>    print u'%d slabs of spam,' % count
>    print u'Send one to abuse and Just Hit Delete,'
>    count += 1
>    print u'%d slabs of spam in my mail!' % count
>    print u''
> The braces are gone, and with them the holy wars. Whatever brace
> styles Python programmers may happen to use in languages with
> braces, all the Python code looks the same, and while the major
> brace styles illustrated above are a few of many ways the C code
> could be laid out, there's only one real way to do it.
> </quote>
> Has the fact changed that Python does not care about (1) how
> many characaters you use for indentation, (1a) you can use tabs
> OR spaces, (2) indentation does not have to be consistent across
> a module, (3) not even across a file, (4) even in nested blocks
> and (5) you can even switch from spaces to tabs and back in the
> same file? So much for 'all the Python code looks the same'.

Since we're harping on block delimitation, I'll plug a post I did on
the subject a little while ago:

Hopefully it's more thorough than the OP's.


More information about the Python-list mailing list