POV-Ray : Newsgroups : povray.off-topic : All bow to the mighty Python Server Time
4 Sep 2024 17:20:46 EDT (-0400)
  All bow to the mighty Python (Message 41 to 50 of 84)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 12:10:26
Message: <4bcf2372$1@news.povray.org>
Invisible wrote:
> Darren New wrote:
> 
>> Plus, as you're typing the arguments, it gives you help for each 
>> argument.
>>
>> I.e., so you know whether it's radians or degrees expected.
> 
> Or find out what the hell the order of the argument is...

Yep. Even better than type signatures, when you have three floats in a row.

Or it makes it easy to figure out you can do something like
   Color newcolor = new Color(oldcolor, newalpha)
and see that there's an overload for constructing a color out of the RGB of 
one color and a specific alpha value.

(And no, the "new" is syntactic noise there - it doesn't allocate anything 
on the heap.)

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 12:12:42
Message: <4bcf23fa$1@news.povray.org>
Warp wrote:
>   How is that "fewer keystrokes".

That's "reindenting". I'm talking about indenting as you type. That kind of 
indenting isn't useful in Python, any more than a macro to "add in the 
missing braces" is useful.

>> and you use them *instead* of { and }.
> 
>   { and } have nothing to do with indentation. They aren't even necessary
> for all code blocks.

And indenting isn't necessary for all code blocks in Python. But, like { } 
in C, indenting is necessary when you have several statements on separate 
lines that you want as a block.

I'm saying that indenting isn't a tedious matter of typing the right number 
of tabs on each line in Python.

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 12:13:58
Message: <4bcf2446@news.povray.org>
Invisible wrote:
> As documented, VS doesn't indent things the way *I* like. ;-)

Did you ever adjust it to your liking? There's a bunch of knobs to tweak, 
you know.

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 12:36:52
Message: <4bcf29a4$1@news.povray.org>
Warp wrote:
>> I guess not. I figured you meant "indenting as you type" or something.
>   That's only *part* of it. Autoindentation works on existing lines too.

If existing lines are indented incorrectly, then your code is broken. The 
reason that "auto indenting" is not possible in Python is the same reason 
that "auto bracing" isn't possible in C.

>> What you're saying is "Python using whitespace is stupid because a lot of 
>> web sites don't treat whitespace as significant."  Sure, OK, that's an opinion.
> 
>   I think it's a very valid opinion taking into account the amount of
> programming forums and blogs out there.

Sure. It's just a question of whether you're fixing the wrong problem. It's 
like saying everyone should learn English because most blogs only handle 
ASCII.  People fixed most of the web apps to not corrupt < and >.  People 
who post Python code should do it via web apps that don't corrupt leading 
whitespace in python apps.

Now, I'll grant that the best thing would be to have indent and dedent 
characters or sequences (like trigraphs in C perhaps).  Cutting text from a 
Python file should insert said trigraphs, and text editors that understand 
python could turn them back into appropriate indentation. (Using the generic 
"you":) But reducing *my* productivity during coding simply because *you* 
are too lazy to not corrupt my source code is not a good thing.

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 12:49:22
Message: <4bcf2c92@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> If existing lines are indented incorrectly, then your code is broken. The 
> reason that "auto indenting" is not possible in Python is the same reason 
> that "auto bracing" isn't possible in C.

  Actually, I can't think why "auto-bracing" wouldn't be possible in C,
at least if you don't mind having braces even around single-statement blocks
(something which many programming guides actually recommend).

  Every time you write a statement which is followed by a code block (even
if it's an empty one in rare cases), such as a for-loop, the editor could
automatically add the '{' and '}' characters and indent the code such that
you can just keep typing the contents of the loop. (The only think which
would slightly interrupt the flow would be that when you end writing the
code block you need to exit it by pressing the down cursor a couple of
times...)

  Hmm, maybe I'll try to make emacs do exactly that. At least by binding
that functionality to some key...

  A lesser variation of that would be that every time you write a '{' the
editor automatically adds (and indents) a '}'. The editor could actually
constantly keep matching braces auto-indented, even if one of the pair is
changed somehow (most editors, including emacs, can highlight matching
braces, so it shouldn't be a problem to auto-indent them as well).

-- 
                                                          - Warp


Post a reply to this message

From: Jim Charter
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 13:01:42
Message: <4bcf2f76$1@news.povray.org>
Warp wrote:
> nemesis <nam### [at] gmailcom> wrote:
>> http://www.itworld.com/government/105031/will-wall-street-require-python
> 
>   Python must have the most idiotic block delimiter in the history of
> programming languages: Whitespace indentation.
> 
>   Why is it idiotic? Because whitespace is the one thing which gets most
> easily and regularly lost in communication.
> 
>   For example, someone might ask some question about Python in a forum or
> blog post, and then someone might answer it with some Python code... and
> the blog/forum software removes whitespaces from the beginning of lines,
> completely changing the meaning of the program and making it inoperable.
> There are also many other situations where whitespaces at the beginning
> of lines might not be preserved (or might be changed somehow).
> 
>   Also autoindentation of Python code is a physical impossibility.
> 
>   The person who thought that it's a good idea to have indentation as
> block delimiters should be shot.
> 

So you are saying that the programming language is no good unless it 
allows production code to be floated around on blogs?


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 13:16:39
Message: <4bcf32f7@news.povray.org>
Jim Charter <jrc### [at] msncom> wrote:
> So you are saying that the programming language is no good unless it 
> allows production code to be floated around on blogs?

  No, I'm saying that using whitespace as syntax is a bad idea.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 13:25:00
Message: <4bcf34ec$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> If existing lines are indented incorrectly, then your code is broken. The 
>> reason that "auto indenting" is not possible in Python is the same reason 
>> that "auto bracing" isn't possible in C.
> 
>   Actually, I can't think why "auto-bracing" wouldn't be possible in C,
> at least if you don't mind having braces even around single-statement blocks
> (something which many programming guides actually recommend).

This is why:  Take all the braces out of a C program. Now put them back in 
the right place.  That's what you're asking.

Distinguish between "indent Python not knowing how much it should be 
indented" and "indent changing python when the program is already correctly 
indented so far."

Your editor can indent when necessary, and unindent with a keystroke, as you 
type. This is the equivalent of your "you write a statement which is 
followed by a code block" statement. Cut and paste can automatically put 
things as the right indent level (with a python-aware editor, of course). Etc.

Statements that should be aligned that aren't can be fixed. If you have four 
lines under your "if" with slightly varying indents but all indented 
relative to the "if", then this is trivial to fix. (Python might already be 
happy with that one, actually.)

The only failure is when you have something that should be indented relative 
to a line above it somewhere but it isn't. This is precisely analogous to 
having the wrong number of closing braces. Asking for this to be fixed 
automatically is identical to asking for C code with too many closing braces 
to get fixed automatically. You can't do it, because you don't know how 
indented it is *supposed* to be, just like you don't know which closing 
brace is the one that ought be removed.  (I'm sure you've encountered this 
at least once. :-)

Indeed, I wouldn't be surprised if it was trivial to program a python editor 
that } at the start of a line translates to a dedent. :-)

>   Every time you write a statement which is followed by a code block (even
> if it's an empty one in rare cases), such as a for-loop, the editor could
> automatically add the '{' and '}' characters and indent the code such that
> you can just keep typing the contents of the loop.

Lots of HTML editors do this too.

>   A lesser variation of that would be that every time you write a '{' the
> editor automatically adds (and indents) a '}'. The editor could actually
> constantly keep matching braces auto-indented, even if one of the pair is
> changed somehow (most editors, including emacs, can highlight matching
> braces, so it shouldn't be a problem to auto-indent them as well).

Yep. Visual Studio does this.

Python doesn't need to. ;-)

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Darren New
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 13:25:38
Message: <4bcf3512@news.povray.org>
Warp wrote:
> Jim Charter <jrc### [at] msncom> wrote:
>> So you are saying that the programming language is no good unless it 
>> allows production code to be floated around on blogs?
> 
>   No, I'm saying that using whitespace as syntax is a bad idea.

So is lower case letters, because EBCDIC doesn't support that. :-)

-- 
Darren New, San Diego CA, USA (PST)
   Linux: Now bringing the quality and usability of
   open source desktop apps to your personal electronics.


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 13:49:22
Message: <4bcf3aa1@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> > Jim Charter <jrc### [at] msncom> wrote:
> >> So you are saying that the programming language is no good unless it 
> >> allows production code to be floated around on blogs?
> > 
> >   No, I'm saying that using whitespace as syntax is a bad idea.

> So is lower case letters, because EBCDIC doesn't support that. :-)

  Yeah, I see how EBCDIC is as popular as html.

  (Besides, EBCDIC does support lowercase letters.)

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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