[oclug] Evolution problem
rod at giffinscientific.com
Tue Jun 17 08:23:37 EDT 2003
On Tue, 2003-06-17 at 00:57, Brad Barnett wrote:
> Did I say that there is simply no need for Python's whitespace
> indentation? Yes, I did. They _force_ it. That's not necessary, and it
> is flawed in implementation. That's what paragraphs are for, keeping
> context. ;)
That's what whitespace indentation is for in program code, context. It
demark blocks of code so that it is more readable by humans, and in the
case of Python to demark blocks of code for the Python interpreter.
They could just as easily used braces to demark code, but that doesn't
necessarily make the code easier to read. The author(s) opted for a
compromise that works quite well if you follow a simple rule... Keep
away from the tab key unless your editor inserts spaces instead of tab
> > Nonetheless, I'll rephrase:
> > > I said Python's whitespace indentation causes problems. Keep my
> > > sentences in context, please.
> > So, in what way is whitespace indentation in Python problematic, or
> > flawed if you will, then?
> Do some searches on google, and feel the pain. The immense pain some
> people have had over this issue. You see, Python accepts tabs or spaces
> as whitespaces, identifying a tab as 8 spaces. On the other hand,
> tabs are rendered as 4 or 8 spaces, depending on the editor, and on the os
> the editor is running on.
That is incorrect. Python can use space delimiting if you want. If you
use the tab key instead of the space bar, you are inviting problems.
It's a question of style. Python enforces good programming style, a
nice clean human readable format. Many editors have programmable number
of spaces that can be inserted with the tab key, and also have a
maintainable indent. If a programmer has trouble with this, they could
switch to a more sophisticated editor.
> So, you end up with code that can be a pain to use by someone else.
> People can mix tabs and spaces in a Python file, leading to all sorts of
> mixups. What looks perfectly fine on one OS may not look fine on another.
> You have to make sure your editor always renders tabs as 8 spaces, or
> that it converts tabs to spaces (even better). If a Python file is posted
> to the web, a cut and paste may result in an inaccurate conversion of
> tab -> space.
> A small thing, some people say. It's not though, not when it is
> completely unnecessary. It's an example of form before function, of
> trying to make something ascetically pleasing, in a flawed way, before
> making it functional.
You have to have some method of demarking blocks of code, otherwise you
cannot predict how your program will function. Python does not use
endif statements or braces, for example. It uses the level of
indentation to group the code blocks. There's nothing inherently wrong
with that - and it also has the effect of making the code more readable.
> Tabs should not even have been allowed in Python code, if this is the way
> they wanted it, but they simple couldn't get it right.
Well, what can I say. Use an editor that inserts spaces instead of
tabs. Tab's are for typists, not program code.
More information about the OCLUG