Indentation/whitespace
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Sat Dec 24 06:36:25 EST 2005
On Fri, 23 Dec 2005 15:31:55 -0800, thakadu wrote:
> I consider myself a fairly experienced Python coder and although I am
> not "uncomfortable" with significant whitespace there are a few places
> where I do find it annoying and I wouldnt mind an alternate block
> delimitation syntax. I would prefer something like the ruby "end"
> though rather than '{' and '}'.
Python already has support for begin/end if you want it. It is spelt
"# BEGIN" and "# END" (or "#END IF", etc.), and is case-insensitive.
In most programming languages, begin/end markers are syntactically
significant while indentation is recommended but not enforced by the
compiler. In Python, it is the other way around.
> The place I find it annoying is in
> pasting snippets of code from say web pages. I very often google for a
> piece of code and then paste it into my editor and almost always the
> pasted piece of code has different indentation and causes a compiler
> error.
That's hardly Python's fault. That's a problem with lousy browsers,
editors etc. which add word-wrapping or remove whitespace. Complain to the
browser developers.
--
Steven.
More information about the Python-list
mailing list