POV-Ray : Newsgroups : povray.off-topic : All bow to the mighty Python : Re: All bow to the mighty Python Server Time
4 Sep 2024 17:22:43 EDT (-0400)
  Re: All bow to the mighty Python  
From: Neeum Zawan
Date: 22 Apr 2010 01:08:46
Message: <4bcfd9de$1@news.povray.org>
On 04/20/10 13:31, Warp wrote:
> Neeum Zawan <m.n### [at] ieeeorg> wrote:
>>         Well, OK - occasionally had issues with people mixing tabs with spaces,
>> but then I learned to use a proper editor.<G>
> 
>   How does the Python interpreter/compiler even work with different types of
> whitespace? If, for example, one line as 4 spaces at the beginning and the
> next line has one tab character (which many editors will show as wide as
> 8 spaces, and in fact some editors will convert groups of 8 spaces into
> tabs), how does the interpreter interpret that? And what happens if you
> change the tab width in your editor settings?

	Mixing tabs and spaces is the only whitespace error I've come across in
Python. And I can count on one hand how often it's happened to me. And
as I said, the solution was simple: Use a proper editor that'll convert
the tabs to spaces.

>   I bet it can become pretty confusing when the interpreter is giving you
> error messages or, much worse, it will parse ok but run complately wrongly,
> even though it *looks* to be ok.

	If you mix tabs and spaces within an intended block, the program won't
run. If they're in separate blocks, it will run (properly).

>   Relying on the use of whitespace for actual syntax is idiotic (with the
> exception of separating tokens with at least one whitespace character,
> while not being important how many).

	Merely an opinion.

>>         Know how often I've had issues compiling because of a missing brace or
>> semicolon? Orders of magnitude more frequently than whitespace issues in
>> Python.
> 
>   I'm not concerned about typos. I'm concerned about whitespaces being lost
> in transfer and different types of whitespace (spaces, different types of
> tab characters..) being interpreted differently by different programs (the
> text editor might be showing you something completely different than what
> the Python interpreter is seeing).

	Seems like a minor concern to me. As you're a professional programmer,
I suppose you often have to go to poorly coded forums. The ones I go to
allow you to post code that the software won't reformat. The only
exception being blog comments - and I rarely need to post code in a blog
comment.
		
>   Whitespace at the beginning of lines should be purely aesthetical, not
> integral part of the syntax.

	And a semicolon at the end shouldn't be mandatory, and should only be
needed if you want more than one statement per line. If you seriously
think about it, a huge percentage of semicolons in code are merely
wasted characters that just don't need to be there. It's easier to have
a syntax where you *explicitly* specify that the statement is longer
than one line, because those are the *exceptions*.
		
>>         Once I had spent just a short amount of time in the Python world, I
>> really hated semicolons in whatever other language I was coding in. A
>> royal pain to have to enter a mostly pointless character after each
>> statement.
> 
>   You seem to assume that statements never get longer than a certain length,
> so that they will all nicely fit in one line. Sometimes it's useful to be
> able to split statements into several lines.

	Python has no problem dealing with statements that are on multiple
lines, as long as you write them properly. The "benefit" of semicolons
is quite the opposite - it allows multiple statements per line.

>>         Most online forums have a [code] tag or something similar to ensure
>> nothing gets formatted.
> 
>   Except that many don't.

	And why would I try to post code to one that didn't? I wouldn't do it
even if whitespace was not a syntactical feature.

>> Otherwise, use a pasting service.
> 
>   Why should I have to use such things just because the language has a
> braindead idea of using whitespace as syntax?

	Designing a language because of poorly written forum software is a bit
more braindead. Seriously, can you imagine this as being an issue the
C++ standards committee should bother looking into at all? How to make
code appear properly online?

>>>   Also autoindentation of Python code is a physical impossibility.
> 
>>         Why would this be a concern?
> 
>   Because when your editor can autoindent your code, it makes programming
> enormously easier (similarly to how syntax highlighting does).

	I simply don't see a need for this in Python. If the code has wrong
indentation, then it's not merely indentation that is wrong. The code is
wrong. You can't autoindent incorrect code.

	In fact - one of the benefits of Python *is* that this is not an issue.
The need to autoindent arises because a language allows its users to be
sloppy while writing it.

-- 
To call a man an ass is to insult the jackass.  M.Twain


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.