Language design

Chris Angelico rosuav at gmail.com
Fri Sep 13 07:16:49 EDT 2013


On Fri, Sep 13, 2013 at 8:13 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Fri, 13 Sep 2013 09:04:06 +0200, Antoon Pardon wrote:
>
>> Op 10-09-13 12:20, Chris Angelico schreef:
>>> On Tue, Sep 10, 2013 at 4:09 PM, Steven D'Aprano <steve at pearwood.info>
>>> wrote:
>>>> What design mistakes, traps or gotchas do you think Python has?
>>>> Gotchas are not necessarily a bad thing, there may be good reasons for
>>>> it, but they're surprising.
>>>
>>> Significant indentation. It gets someone every day, it seems.
>>>
>>>
>> Not only that. There are a lot of python code snippets on the net that
>> for whatever reason lost their indentation. There is no algorithm that
>> can restore the lost structure.
>
> Is there an algorithm that will restore the lost structure if you delete
> all the braces from C source code?
>
> Perhaps if web sites and mail clients routinely deleted braces, we'd see
> the broken-by-design software being fixed instead of blaming the language.

While I don't deny your statement, I'd like to point out that English
usually isn't overly concerned with formatting. You can take this
paragraph of text, unwrap it, and then reflow it to any width you
like, without materially changing my points. C follows a rule of
English which Python breaks, ergo software designed to cope only with
English can better cope with C code than with Python code. Removing
all braces would be like removing all punctuation - very like, in fact
- a very real change to the content, and destruction of important
information. Python is extremely unusual in making indentation
important information, thus running afoul of systems that aren't meant
for any code.

But if you look at the quoted text above, I specifically retained your
declaration that "Gotchas are not necessarily a bad thing" when citing
significant indentation. I'm not here to argue that Python made the
wrong choice; I'm only arguing that it frequently confuses people.

ChrisA



More information about the Python-list mailing list