Re: Ohnoes significant whitespace (was: Considering migrating to Python from Visual Basic 6 for engineering applications)

2016-02-19 Thread Grant Edwards
On 2016-02-19, Ben Finney <ben+pyt...@benfinney.id.au> wrote:

> So I am sympathetic to Python newcomers recoiling in horror from
> significant whitespace, *before* they try it. And because of that, we
> are burdened with forever needing to deal with that reaction and
> soothing it.

The first time I wrote Python (it was the only language I could find
that was free and for which I found understandable examples on how to
suck e-mail messages out of Outlook using DCOM -- which was the
problem to be solved), I had an initial aversion to the "significant
whitespace" concept.  That immediately vanished once I started working
on my first Python code.  That was Python 1.5.2 back in 1999.  Shortly
after that, I went to the trouble to add raw socket support to the
Python standard library "socket" module so that I could use Python for
some other tasks. :)

> Those people who claim to have tried Python and *still* complain
> about “significant whitespace”, I have no sympathy for.

I, on the other hand, do feel sorry for them because their brains are
evidently broken in some basic manner that can't help but cause them
suffering.

>  Python clearly does it right, and it's a huge boon to readability
> and reducing simple errors.

Indeed.

-- 
Grant Edwards   grant.b.edwardsYow! Used staples are good
  at   with SOY SAUCE!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ohnoes significant whitespace

2016-02-18 Thread Marko Rauhamaa
Ben Finney <ben+pyt...@benfinney.id.au>:

> So I am sympathetic to Python newcomers recoiling in horror from
> significant whitespace, *before* they try it. And because of that, we
> are burdened with forever needing to deal with that reaction and
> soothing it.

I remember being *very* doubtful how the whitespace would work in
practice. I was won over by a colleague who had sloppy indentation
habbits in C++ but produced tidy, readable code in Python.

> Those people who claim to have tried Python and *still* complain about
> “significant whitespace”,

I am bitten by it occasionally. The editor doesn't know from the context
how a line or block should be (re)indented. In Emacs, TAB, BS and C-M-\,
which keep source code properly indented in other programming languages,
have been known to lead to accidental bugs in Python code. (The proper
way in Emacs is to use C-> and C-< to manipulate blocks of Python code.)

> I have no sympathy for. Python clearly does it right, and it's a huge
> boon to readability and reducing simple errors.

I don't mind Python's syntax. It's the implicit semicolons of JavaScript
and Go that I dislike.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Ohnoes significant whitespace (was: Considering migrating to Python from Visual Basic 6 for engineering applications)

2016-02-18 Thread Ben Finney
Chris Angelico <ros...@gmail.com> writes:

> I'm talking about how people, those bags of flesh and thoughts, are
> bugged out by the notion that *whitespace* should matter (other than
> the mere presence/absence of it). It's the price you pay for being
> different - people will have trouble comprehending you.

To be fair, there is good reason for the programming (and broader IT)
community to have a heuristic of “significant whitespace is probably
bad”.

The few languages that did this badly (Makefile syntax, some Unix shell
syntax) leave a legacy of countless headaches and you can't fix the
language retroactively without breaking backward compatibility.

So I am sympathetic to Python newcomers recoiling in horror from
significant whitespace, *before* they try it. And because of that, we
are burdened with forever needing to deal with that reaction and
soothing it.

Those people who claim to have tried Python and *still* complain about
“significant whitespace”, I have no sympathy for. Python clearly does it
right, and it's a huge boon to readability and reducing simple errors.

-- 
 \   “He was the mildest-mannered man / That ever scuttled ship or |
  `\   cut a throat.” —“Lord” George Gordon Noel Byron, _Don Juan_ |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-04 Thread Steve Holden
r0g wrote:
 David Robinow wrote:
 On Sun, Jan 3, 2010 at 10:42 PM, Roy Smith r...@panix.com wrote:
 In article mailman.386.1262576043.28905.python-l...@python.org,
  David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
 More than not required, it was not relevant.  This led to one of the
 most infamous programming blunders in the early days of the space program,
 when one programmer accidentially typed a period instead of a comma
 resulting in the loss of a satellite:
 Interesting story. Did you make it up?
 It's a fairly well known story.

 http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
  Sure. But the question is, Who made it up?
 http://en.wikiquote.org/wiki/Fortran

 Computer folklore has incorrectly attributed the loss of the Mariner 1
 space probe to a syntax error in a Fortran program. For example,
 Recall the first American space probe to Venus, reportedly lost
 because Fortran cannot recognize a missing comma in a DO statement…[
 
 
 
 Wow you're totally right! It was a missing UNDERSCORE not a DOT being
 typed instead of a COMMA! We've been lied to ALL ALONG! What kind of
 sickos would do this? Let's find this Tim character, flay him alive and
 then go crown you the KING OF EVERYTHING for rescuing us from that
 deadly nugget of misinformation!
 
 Honestly I might have believed those dot/comma LIES if it wasn't for
 your noble selfless efforts to uncover the SHOCKING TRUTH. Imagine what
 might have happened! The character in question being an UNDERSCORE
 COMPLETELY CHANGES the meaning and point of the story. As for it being
 LEFT OUT rather than TRANSPOSED, well, anyone can see how that TURNS THE
 WHOLE STORY UPSIDE DOWN.
 
 Of course there are the naysayers who might claim absolute accuracy is
 no big deal in stories that are essentially parables but they do not
 understand the HARM that can come from not remembering really tiny,
 almost inconsequential details. For what it's worth I DO NOT consider
 you a tiresome pedant and I think your taunting, patronising style is
 completely appropriate and proportional to Tim's sickening crimes
 against fact.
 
 Roger.

Personally I think the overall tone of this group would have been
marginally improved if you had summoned the self-restraint to simply not
make this posting.

Fortunately it's still an unmoderated group, so you can continue to be
as hostile and snarky as you like.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Off Topic ( was Re: Significant whitespace)

2010-01-04 Thread r0g
Steve Holden wrote:
 r0g wrote:
 David Robinow wrote:
 On Sun, Jan 3, 2010 at 10:42 PM, Roy Smith r...@panix.com wrote:
 In article mailman.386.1262576043.28905.python-l...@python.org,
  David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
 More than not required, it was not relevant.  This led to one of the
 most infamous programming blunders in the early days of the space 
 program,
 when one programmer accidentially typed a period instead of a comma
 resulting in the loss of a satellite:
 Interesting story. Did you make it up?
 It's a fairly well known story.

 http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
  Sure. But the question is, Who made it up?
 http://en.wikiquote.org/wiki/Fortran
snip
 completely appropriate and proportional to Tim's sickening crimes
 against fact.

 Roger.
 
 Personally I think the overall tone of this group would have been
 marginally improved if you had summoned the self-restraint to simply not
 make this posting.
 
 Fortunately it's still an unmoderated group, so you can continue to be
 as hostile and snarky as you like.
 
 regards
  Steve



Well I could say the same thing Steve: you could also not have posted
and thereby spared the group even more off topic noise, I'd have quite
happily left it there. Of course our emotional urges trump rationality
almost every time so I understand your urge to address what has upset
you, much as I hope you understand my subsequent urge to respond.

I appreciate this is a professional programming forum and that my post
was crass in the extreme but I get really fed up with the needless
pedantry of computer geeks sometimes; not to mention the insufferably
sanctimonious tone they adopted whilst engaging in it. It ranges from
semi-conscious passive aggression to out and out dick swinging and I
think the overall tone of this group would be marginally improved by
doing away with it.

There are perfectly good way's of putting things that don't require
taunting and smugness. Contrast the clearly snarky personal challenge...

Interesting story. Did you make it up?

...with the far more convivial correction...

Interestingly it was a missing underscore character ;) see
http://example.com/rahrarhrah;...

Both could satisfy the inner pedant's demands for attention, why choose
the first? Personally I think the first respondent should have summoned
the self restraint to just let it drop too, but they didn't and I feel
they did the OP an injustice by that.

My apologies for the noise everybody, I shall say no more on the subject.

Cheers,

Roger.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread John Machin
On Jan 2, 10:29 am, Roy Smith r...@panix.com wrote:


 To address your question more directly, here's a couple of ways Fortran
 treated whitespace which would surprise the current crop of
 Java/PHP/Python/Ruby programmers:

 1) Line numbers (i.e. the things you could GOTO to) were in column 2-7
 (column 1 was reserved for a comment indicator).  This is not quite
 significant whitespace, it's more like significant indentation.

That would also surprise former FORTRAN programmers (who rarely
referred to the language as Fortran). A comment was signified by a C
in col 1. Otherwise cols 1-5 were used for statement labels (the
things you could GOTO), col 6 for a statement continuation indicator,
cols 7-72 for statement text, and cols 73-80 for card sequence numbers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread Mensanator
On Jan 1, 4:02�pm, Dan Stromberg drsali...@gmail.com wrote:
 I put together a page about significant whitespace (and the lack thereof).

The real problem is your use of proportional spaced fonts.


 You're invited to check it out:

 http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread Tim Roberts
Roy Smith r...@panix.com wrote:

2) Whitespace was not required in many places.  For example, the following 
two statements (this will only make sense in a fixed-width font) are 
identical:

   DO 10 I = 1, 10
   DO10I=1,10

More than not required, it was not relevant.  This led to one of the
most infamous programming blunders in the early days of the space program,
when one programmer accidentially typed a period instead of a comma
resulting in the loss of a satellite:

   DO 10 I = 1. 10

What this actually does is store the floating point value 1.1 in a new
variable called DO10I.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread Roy Smith
In article eqf2k5pna25hb0v7a30p9dpcmsvt46s...@4ax.com,
 Tim Roberts t...@probo.com wrote:

 Roy Smith r...@panix.com wrote:
 
 2) Whitespace was not required in many places.  For example, the following 
 two statements (this will only make sense in a fixed-width font) are 
 identical:
 
DO 10 I = 1, 10
DO10I=1,10
 
 More than not required, it was not relevant.  This led to one of the
 most infamous programming blunders in the early days of the space program,
 when one programmer accidentially typed a period instead of a comma
 resulting in the loss of a satellite:
 
DO 10 I = 1. 10
 
 What this actually does is store the floating point value 1.1 in a new
 variable called DO10I.

1.1 or 1.01?  There were some places where a blank was equivalent to a zero 
in a number. I don't remember if this was one of them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread David Robinow
On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
 More than not required, it was not relevant.  This led to one of the
 most infamous programming blunders in the early days of the space program,
 when one programmer accidentially typed a period instead of a comma
 resulting in the loss of a satellite:
Interesting story. Did you make it up?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread Roy Smith
In article mailman.386.1262576043.28905.python-l...@python.org,
 David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
  More than not required, it was not relevant.  This led to one of the
  most infamous programming blunders in the early days of the space program,
  when one programmer accidentially typed a period instead of a comma
  resulting in the loss of a satellite:
 Interesting story. Did you make it up?

It's a fairly well known story.

http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread David Robinow
On Sun, Jan 3, 2010 at 10:42 PM, Roy Smith r...@panix.com wrote:
 In article mailman.386.1262576043.28905.python-l...@python.org,
  David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
  More than not required, it was not relevant.  This led to one of the
  most infamous programming blunders in the early days of the space program,
  when one programmer accidentially typed a period instead of a comma
  resulting in the loss of a satellite:
 Interesting story. Did you make it up?

 It's a fairly well known story.

 http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
 Sure. But the question is, Who made it up?
http://en.wikiquote.org/wiki/Fortran

Computer folklore has incorrectly attributed the loss of the Mariner 1
space probe to a syntax error in a Fortran program. For example,
Recall the first American space probe to Venus, reportedly lost
because Fortran cannot recognize a missing comma in a DO statement…[
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread r0g
David Robinow wrote:
 On Sun, Jan 3, 2010 at 10:42 PM, Roy Smith r...@panix.com wrote:
 In article mailman.386.1262576043.28905.python-l...@python.org,
  David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
 More than not required, it was not relevant.  This led to one of the
 most infamous programming blunders in the early days of the space program,
 when one programmer accidentially typed a period instead of a comma
 resulting in the loss of a satellite:
 Interesting story. Did you make it up?
 It's a fairly well known story.

 http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
  Sure. But the question is, Who made it up?
 http://en.wikiquote.org/wiki/Fortran
 
 Computer folklore has incorrectly attributed the loss of the Mariner 1
 space probe to a syntax error in a Fortran program. For example,
 Recall the first American space probe to Venus, reportedly lost
 because Fortran cannot recognize a missing comma in a DO statement…[



Wow you're totally right! It was a missing UNDERSCORE not a DOT being
typed instead of a COMMA! We've been lied to ALL ALONG! What kind of
sickos would do this? Let's find this Tim character, flay him alive and
then go crown you the KING OF EVERYTHING for rescuing us from that
deadly nugget of misinformation!

Honestly I might have believed those dot/comma LIES if it wasn't for
your noble selfless efforts to uncover the SHOCKING TRUTH. Imagine what
might have happened! The character in question being an UNDERSCORE
COMPLETELY CHANGES the meaning and point of the story. As for it being
LEFT OUT rather than TRANSPOSED, well, anyone can see how that TURNS THE
WHOLE STORY UPSIDE DOWN.

Of course there are the naysayers who might claim absolute accuracy is
no big deal in stories that are essentially parables but they do not
understand the HARM that can come from not remembering really tiny,
almost inconsequential details. For what it's worth I DO NOT consider
you a tiresome pedant and I think your taunting, patronising style is
completely appropriate and proportional to Tim's sickening crimes
against fact.

Roger.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-03 Thread Steven D'Aprano
On Sun, 03 Jan 2010 23:42:44 -0500, David Robinow wrote:

 On Sun, Jan 3, 2010 at 10:42 PM, Roy Smith r...@panix.com wrote:
 In article mailman.386.1262576043.28905.python-l...@python.org,
  David Robinow drobi...@gmail.com wrote:

 On Sun, Jan 3, 2010 at 8:09 PM, Tim Roberts t...@probo.com wrote:
  More than not required, it was not relevant.  This led to one of
  the most infamous programming blunders in the early days of the
  space program, when one programmer accidentially typed a period
  instead of a comma resulting in the loss of a satellite:
 Interesting story. Did you make it up?

 It's a fairly well known story.

 http://catless.ncl.ac.uk/Risks/5.64.html#subj4.2
  Sure. But the question is, Who made it up?
 http://en.wikiquote.org/wiki/Fortran
 
 Computer folklore has incorrectly attributed the loss of the Mariner 1
 space probe to a syntax error in a Fortran program. For example, Recall
 the first American space probe to Venus, reportedly lost because Fortran
 cannot recognize a missing comma in a DO statement…[


What makes you believe it is incorrect?



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-02 Thread Duncan Booth
Donn donn.in...@gmail.com wrote:

 On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote:
 I put together a page about significant whitespace (and the lack
 thereof). 
 The only thing about Python's style that worries me is that it can't
 be compressed like javascript can*, and perhaps that will prevent it
 becoming a browser-side language one day. How I'd love to code PyQuery
 instead of JQuery! 

You can do simple white-space removal as easily in Python as in Javascript, 
you just need to maintain a minimal indentation and as you don't need 
Javascript's curly braces there probably isn't must difference especially 
once the code has been gzipped for transfer to the browser.

You can already run Python client side in certain situations (e.g. 
Silverlight), but if you want to write Python for the browser portably 
today have a look at Pyjamas http://code.google.com/p/pyjamas/ .

Google's Chrome also supports native code (currently just for x86 machines 
though they have said they intend to support ARM), so there should be some 
potential there to compile a Python interpreter that runs client-side in 
Google's sandbox: see http://plash.beasts.org/wiki/NativeClient for an 
early port.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-02 Thread Steven D'Aprano
On Sat, 02 Jan 2010 10:42:39 +, Duncan Booth wrote:

 Donn donn.in...@gmail.com wrote:
 
 On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote:
 I put together a page about significant whitespace (and the lack
 thereof).
 The only thing about Python's style that worries me is that it can't be
 compressed like javascript can*, and perhaps that will prevent it
 becoming a browser-side language one day. How I'd love to code PyQuery
 instead of JQuery!
 
 You can do simple white-space removal as easily in Python as in
 Javascript, you just need to maintain a minimal indentation and as you
 don't need Javascript's curly braces there probably isn't must
 difference especially once the code has been gzipped for transfer to the
 browser.

I don't understand why you would bother removing whitespace, particularly 
if you're going to gzip the file anyway.

I've just picked one of my modules at random: about 47K in size, of which 
about 15K is whitespace. Compressed to .bz, it is 12K, and if I strip the 
whitespace from it first and then compress it, it is 11K.

So, even though whitespace (spaces and newlines) make up about 30% of the 
original source, once compressed they represent only about 8%. Given the 
extra complexity of stripping whitespace, I don't know that it's 
worthwhile. It's not like you're going to reduce the download time from 
three hours to one; it's more like 2 seconds to 1.5.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-02 Thread Emile van Sebille

On 1/1/2010 5:05 PM Steven D'Aprano said...

In Python terms, imagine if we could write

 foriinrange(10):

instead of the usual

 for i in range(10):

Since the colon makes it unambiguous that it is some sort of block
construct, and it starts with for, it must be a for loop. Pretty
horrible, yes?



Yes -- early on I got stung by something similar.  My first programming 
job (1977?) was working in a basic dialect called Buisness Basic Level 
II (BBII).  To delete a record in the file you used a remove statement. 
 White space on the line was optional, allowing you to write lines like 
'100 remove(1,key=k$)' and '100 fori=1to10'.  REM was how a remark 
statement began, which allowed statements like 100 REM comment.  I was 
sent on-site to a customer running the prior version (BBI).  I didn't 
realize the REMOVE command changed between versions from REKEY, and it 
was only after a more experienced programmer co-wroker pointed out that 
my REMOVE statement was being interpreted as a REM that I finally found 
the bug I'd created.


Manuals and documentation, while often lacking, are as often underrated.

Emile


--
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-02 Thread Mensanator
On Jan 2, 4:19 pm, Emile van Sebille em...@fenx.com wrote:
 On 1/1/2010 5:05 PM Steven D'Aprano said...

  In Python terms, imagine if we could write

       foriinrange(10):

  instead of the usual

       for i in range(10):

  Since the colon makes it unambiguous that it is some sort of block
  construct, and it starts with for, it must be a for loop. Pretty
  horrible, yes?

 Yes -- early on I got stung by something similar.  My first programming
 job (1977?) was working in a basic dialect called Buisness Basic Level
 II (BBII).  To delete a record in the file you used a remove statement.
   White space on the line was optional, allowing you to write lines like
 '100 remove(1,key=k$)' and '100 fori=1to10'.  REM was how a remark
 statement began, which allowed statements like 100 REM comment.  I was
 sent on-site to a customer running the prior version (BBI).  I didn't
 realize the REMOVE command changed between versions from REKEY, and it
 was only after a more experienced programmer co-wroker pointed out that
 my REMOVE statement was being interpreted as a REM that I finally found
 the bug I'd created.

Better than the other way 'round, eh?


 Manuals and documentation, while often lacking, are as often underrated.

 Emile

-- 
http://mail.python.org/mailman/listinfo/python-list


Significant whitespace

2010-01-01 Thread Dan Stromberg


I put together a page about significant whitespace (and the lack thereof).

You're invited to check it out:

http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html


--
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 2:02 PM, Dan Stromberg drsali...@gmail.com wrote:
 I put together a page about significant whitespace (and the lack thereof).

 You're invited to check it out:

 http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html

For those of us who weren't around during the heyday of FORTRAN, can
anyone describe this apparently much-reviled significant whitespace
feature that continues to make some programmers unjustly fearful about
Python's use of indentation?

Thanks in advance.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Roy Smith
In article mailman.319.1262384371.28905.python-l...@python.org,
 Chris Rebert c...@rebertia.com wrote:

 On Fri, Jan 1, 2010 at 2:02 PM, Dan Stromberg drsali...@gmail.com wrote:
  I put together a page about significant whitespace (and the lack thereof).
 
  You're invited to check it out:
 
  http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html
 
 For those of us who weren't around during the heyday of FORTRAN, can
 anyone describe this apparently much-reviled significant whitespace
 feature that continues to make some programmers unjustly fearful about
 Python's use of indentation?

 I know it's bad form to cite yourself, but I think I said it pretty well 
(oh my) 12 years ago:

http://www.python.org/doc/humor/#bad-habits

To address your question more directly, here's a couple of ways Fortran 
treated whitespace which would surprise the current crop of 
Java/PHP/Python/Ruby programmers:

1) Line numbers (i.e. the things you could GOTO to) were in column 2-7 
(column 1 was reserved for a comment indicator).  This is not quite 
significant whitespace, it's more like significant indentation.

2) Whitespace was not required in many places.  For example, the following 
two statements (this will only make sense in a fixed-width font) are 
identical:

   DO 10 I = 1, 10
   DO10I=1,10

People make fun of Fortran these days, but it was a staggeringly important 
advance in software development compared to what came before (i.e. 
assembler).  The move from assembler to Fortran was a far more significant 
advance than the move from, say, Perl to Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 14:19:28 -0800, Chris Rebert wrote:

 For those of us who weren't around during the heyday of FORTRAN, can
 anyone describe this apparently much-reviled significant whitespace
 feature that continues to make some programmers unjustly fearful about
 Python's use of indentation?


I'm not a Fortran expert, but I understand that whitespace was optional 
within lines unless needed to make something unambiguous.

In Python terms, imagine if we could write

foriinrange(10):

instead of the usual 

for i in range(10):

Since the colon makes it unambiguous that it is some sort of block 
construct, and it starts with for, it must be a for loop. Pretty 
horrible, yes?


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread MRAB

Dan Stromberg wrote:


I put together a page about significant whitespace (and the lack thereof).

You're invited to check it out:

http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html


You might also want to mention that programmers tend to indent anyway
for clarity.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Roy Smith
In article 
3db95947-1e35-4bd1-bd4c-37df646f9...@v25g2000yqk.googlegroups.com,
 John Machin sjmac...@lexicon.net wrote:

 On Jan 2, 10:29 am, Roy Smith r...@panix.com wrote:
 
 
  To address your question more directly, here's a couple of ways Fortran
  treated whitespace which would surprise the current crop of
  Java/PHP/Python/Ruby programmers:
 
  1) Line numbers (i.e. the things you could GOTO to) were in column 2-7
  (column 1 was reserved for a comment indicator).  This is not quite
  significant whitespace, it's more like significant indentation.
 
 That would also surprise former FORTRAN programmers (who rarely
 referred to the language as Fortran). A comment was signified by a C
 in col 1. Otherwise cols 1-5 were used for statement labels (the
 things you could GOTO), col 6 for a statement continuation indicator,
 cols 7-72 for statement text, and cols 73-80 for card sequence numbers.

My apologies, you are correct.  The long disused neural pathways have 
started to degrade.  Trust me, I really did write FORTRAN.  On punch cards 
even.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Donn
On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote:
 I put together a page about significant whitespace (and the lack thereof).
The only thing about Python's style that worries me is that it can't be 
compressed like javascript can*, and perhaps that will prevent it becoming a 
browser-side language one day. How I'd love to code PyQuery instead of JQuery!

* Or am I wrong?
\d
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 9:56 PM, Donn donn.in...@gmail.com wrote:
 On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote:
 I put together a page about significant whitespace (and the lack thereof).
 The only thing about Python's style that worries me is that it can't be
 compressed like javascript can*, and perhaps that will prevent it becoming a
 browser-side language one day. How I'd love to code PyQuery instead of JQuery!

 * Or am I wrong?

Not to my knowledge, but CPython's bytecode format could be used to
similar effect.

However, the larger and much more daunting obstacle to client-side
Python would be that it's not sandboxed or secured like JavaScript is,
although there are some people working on it.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread H J van Rooyen

Dennis Lee Bieber [EMAIL PROTECTED] wrote:

| On 8 Aug 2006 04:59:34 -0700, [EMAIL PROTECTED] declaimed the
| following in comp.lang.python:
|
| 
|  Some of it may be a reaction from old-timers who remember FORTRAN,
|  where (if memory serves), code had to start in column 16 and code
|  continutations had to be an asterik in column 72 (it's been many years
|  since I've done any work in FORTRAN, but you get the idea)
| 
| Comment C in column 1
| (often extended to accept OS JCL markers too)
| Label numeric in 1-5
| Continuation anything in column 6
| (DEC, if using tab indents would take tab)
| Statement column 7-72
| Sequence/ID column 73-80
|
| I forget what COBOL used, but it had a few fields of its own.

The COBOL I used (NCR Century, Burroughs, some little IBM) was not fussy - the
only thing was that like in assembler, you had to start a lable  (that is a
symbolic name for an address) in the first column...

And you *had* to end what Python calls a suite with a fullstop - many hours
spent looking for weird bugs..

The breaking of the link between a lable or name and a memory address of
something is what I think most newcomers to Python find horribly confusing...

- Hendrik



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
[EMAIL PROTECTED] writes
No.  In that case Python makes it more readily apparent that your code is
too complex.

If only life and software engineering was that simple. Not every problem 
can be reduced to one screenful of code, not in the real world anyway.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
Gerhard Fiedler [EMAIL PROTECTED] writes
I mean the code should be written so that as few as possible comments are
necessary to understand it. I don't mean that additional comments are a bad
thing.

Agreed. Concise code is always good.

Just found this on c.l.ruby. Seems kind of relevant.

QUOTE
My apologies if someone has posted this already -- I just received it:

http://www.americanscientist.org/template/AssetDetail/assetid/51982

The Semicolon Wars

Every programmer knows there is one true programming language.
A new  one every week
/QUOTE
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Slawomir Nowaczyk
On Wed, 09 Aug 2006 07:33:41 -0700
Rob Wolfe [EMAIL PROTECTED] wrote:

# Slawomir Nowaczyk wrote:
# 
#  Really, typing brace after function/if/etc should add newlines and
#  indent code as required -- automatically. Actually, for me, it is even
#  *less* typing in C and similar languages... I probably should teach my
#  Emacs to automatically add newline after colon in Python, just as it
#  does after a brace in C... As soon as I figure out how to deal with
#  dictionary literals. Hmmm.
# 
# Are you sure? My Emacs already know how to do it with the help
# of python-mode and magic function py-newline-and-indent.
# 
# emacs-version 21.3.1
# py-version $Revision: 4.63 $

OK, my python-mode.el was older, so I upgraded to 4.75, but it still
doesn't work. Did you mean that after you write

if x==1:

the newline is inserted automatically when you type :? That's a
functionality I would like to see, but it doesn't seem to work this
way.

Anyway, I am using python.el most of the time and it doesn't have that
functionality yet.

-- 
 Best wishes,
   Slawomir Nowaczyk
 ( [EMAIL PROTECTED] )

Live in the past and future only.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Stephen Kellett
In message [EMAIL PROTECTED], Carl
Banks [EMAIL PROTECTED] writes
Stephen Kellett wrote:
I don't really understand how a closing brace helps here.  Care to
explain why it helps you?

(Deeply nested long functions are evil anyways.  If you have such a

I didn't write deeply nested. I wrote multiple levels of indentation.
They are not the same thing (they can be, but they don't have to be). A
lot of code gets to 3 or 4 levels of indentation quite easily. I
wouldn't call that deeply nested, not by a long shot.

To answer your first question: In C++/Ruby/Pascal you'd have something
like this

function()
{
loop1()
{
blah
blah

loop2()
{
blah

loop3()
{
blah
}

blah
}
}

otherloop()
{
blah
}
}

and in Python that gets to

function()
loop1()
blah
blah

loop2()
blah

loop3()
blah

blah3

otherloop()
blah

I really dislike that the end of loop2  is implicit rather than
explicit. If its implicit you have to look for it. And if blah3 didn't
exist then both loop2 and loop3 would be ending implicitly. This problem
gets worse with longer functions and more indentation.  I'm sure some
people are thinking the above is elegant. To me, its clumsy, and here is
why...

Now, the above Python version looks nice, I grant you, but that is
because it is short. I'm talking about long functions which take up some
space. When you come to add loop4, which for arguments sake is after
loop2 but before otherloop() and at the same indentation as loop2, thats
trivial in C/Ruby/etc but in Python I've got to scroll up the screen
find loop2, remembers its indentation go back down and carefully insert
it hoping I've got it right. I don't have do that with C/Ruby etc
because loop2() ends with a brace/end statement so I know its
indentation/end point without having to go and find the start of it
(which is off the screen).

Yes the above example is contrived - so that I could demonstrate what I
wanted to demonstrate. But I've run into these problems with Python code
I've written and when reading code written by others. Its a real
problem, not just one I've cooked up for an argument.

As part of my day job I get to look at a lot of code written by other
people, mainly people I've never met and often people I've never even
traded email with. Strangely, if people have traded email with me, code
that arrives is usually well formatted :-) The amount of code written in
horrible styles is amazing, but if you can't spot the start/end of
loops/conditionals easily and quickly without having to actually read
the code then scanning for the actual code of interest becomes a lot
harder. C/C++ have quite a number of horrible styles (K/R being one)
which can be fixed with a code formatter, but that implicit loop ending
thing with Python I demo above - thats a language feature and nothing I
can do will make that go away.

I'm always thinking maintenance and readability, some time after the
fact. I know that I'll have a reason to come back some time later. Maybe
for a bug fix, a feature improvement or just to lift some code. That is
why stuff like this is important to me. It needs to be as fast,
efficient and error free as possible. And the above doesn't do if for
me.

Now I'm sure some of you will think I'm mad or whatever, but things like
this are important (to me, at least). I don't want to waste my time with
issues like the above. If I'm wasting my time on stuff like this it
can't be that readable can it? If you think the above isn't an issue
we'll just have to agree to disagree.

There some are people on the c.l.ruby newsgroup that love Ruby because
they don't have to type semicolons anymore. Not that its going to change
the world, but its important for them. I think that is one of the least
important things you can think of about Ruby, but there you go.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Rob Wolfe

Slawomir Nowaczyk wrote:
 On Wed, 09 Aug 2006 07:33:41 -0700
 Rob Wolfe [EMAIL PROTECTED] wrote:

 # Slawomir Nowaczyk wrote:
 #
 #  Really, typing brace after function/if/etc should add newlines and
 #  indent code as required -- automatically. Actually, for me, it is even
 #  *less* typing in C and similar languages... I probably should teach my
 #  Emacs to automatically add newline after colon in Python, just as it
 #  does after a brace in C... As soon as I figure out how to deal with
 #  dictionary literals. Hmmm.
 #
 # Are you sure? My Emacs already know how to do it with the help
 # of python-mode and magic function py-newline-and-indent.
 #
 # emacs-version 21.3.1
 # py-version $Revision: 4.63 $

 OK, my python-mode.el was older, so I upgraded to 4.75, but it still
 doesn't work. Did you mean that after you write

 if x==1:

 the newline is inserted automatically when you type :? That's a

Exactly.

 functionality I would like to see, but it doesn't seem to work this
 way.

Here is fragment of my python-mode.el:


The \\[indent-for-tab-command] and \\[py-newline-and-indent] keys try
to suggest plausible indentation, based on
the indentation of preceding statements.  E.g., assuming
py-indent-offset is 4, after you enter
\tif a  0: \\[py-newline-and-indent]
the cursor will be moved to the position of the `_' (_ is not a
character in the file, it's just used here to indicate the location of
the cursor):
\tif a  0:
\t_
If you then enter `c = d' \\[py-newline-and-indent], the cursor will
move
to
\tif a  0:
\tc = d
\t_
Python-mode cannot know whether that's what you intended, or whether
\tif a  0:
\tc = d
\t_
was your intent.  In general, Python-mode either reproduces the
indentation of the (closest code or indenting-comment) preceding
statement, or adds an extra py-indent-offset blanks if the preceding
statement has `:' as its last significant (non-whitespace and non-
comment) character.  If the suggested indentation is too much, use
\\[py-electric-backspace] to reduce it.



Regards,
Rob

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread gslindstrom
Carl Banks wrote:
 Although Python doesn't do this, it is possible to mandate a specific
 indent (4 spaces, say), or at least a reasonable consistent indent  snip

I like running reindent.py (found in your Python source directory under
Tools/Scripts) which cleans up indentations, trailing whitespace, and
other things.  We run our entire source directory through reindent
before we check it into our library.  A very nice routine courtesy of
Tim Peters, I believe.

--greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Rhamphoryncus
Stephen Kellett wrote:
 function()
 loop1()
 blah
 blah

 loop2()
 blah

 loop3()
 blah

 blah3

 otherloop()
 blah

 Yes the above example is contrived - so that I could demonstrate what I
 wanted to demonstrate. But I've run into these problems with Python code
 I've written and when reading code written by others. Its a real
 problem, not just one I've cooked up for an argument.

[much snippage]

I actually agree with you here; when indentation goes on longer than a
screen it can become difficult know what that indentation is associated
with.  Braces may mitigate it somewhat, but not completely.  Some
points to consider:

* Python is inherently shorter than C/C++, so you're less likely to go
over one screen.
* Long functions should usually be refactored anyway and would gain
readability in any language.  The threshold here is smaller in python
because your code will do more significant things, vs C where your
screen gets covered with minutiae that you learn to mentally ignore.

Also, I wonder if a more intelligent editor would help here, one that
would visually indicate blocks as such:

function()
|   loop1()
|   |   blah
|   |   blah
|   |
|   |   loop2()
|   |   |   blah
|   |   |
|   |   |   loop3()
|   |   |   |   blah
|   |   |
|   |   |   blah3
|
|   otherloop()
|   |   blah

Surely this would eliminate the problem?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Carl Banks

[EMAIL PROTECTED] wrote:
 Carl Banks wrote:
  Although Python doesn't do this, it is possible to mandate a specific
  indent (4 spaces, say), or at least a reasonable consistent indent  snip

 I like running reindent.py (found in your Python source directory under
 Tools/Scripts) which cleans up indentations, trailing whitespace, and
 other things.  We run our entire source directory through reindent
 before we check it into our library.  A very nice routine courtesy of
 Tim Peters, I believe.

The very fact the code reindenters exist should tell you that fixed
indent is superior. :)


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Carl Banks
Stephen Kellett wrote:
 I really dislike that the end of loop2  is implicit rather than
 explicit.

So you can't see at a glance how many blocks were closed.  That's fair.
 Add a little chalk mark to the against column.


 C/C++ have quite a number of horrible styles (K/R being one)

Oddly, I never used to use K  R until I was a longtime Python
programmer.  Then I wanted to get those redundant braces as far out of
the way as reasonable; hence K  R.  Maybe someday I'll take up a
LISP-like style and put the closing brace on the last line of the
block.  (No, I won't.)


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Slawomir Nowaczyk
On Thu, 10 Aug 2006 04:01:51 -0700
Rob Wolfe [EMAIL PROTECTED] wrote:

#  if x==1:
# 
#  the newline is inserted automatically when you type :? That's a
# 
# Exactly.

Really? The newline? I know it *indents* automatically. But it
definitely doesn't insert newline when I try it.

I even downloaded revision 4.63 and I really do not see any code for
doing that. py-electric-colon only seems to dedent code.

#  functionality I would like to see, but it doesn't seem to work
#  this way.
# 
# Here is fragment of my python-mode.el:

Please note that this comment doesn't say anything about automatically
inserting newlines, only about indenting (actually, dedenting) as
needed.

Anyway, this is probably becoming off-topic here.

-- 
 Best wishes,
   Slawomir Nowaczyk
 ( [EMAIL PROTECTED] )

Cursor: What you become when your computer crashes.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Gerhard Fiedler
On 2006-08-10 07:40:01, Stephen Kellett wrote:

 To answer your first question: In C++/Ruby/Pascal you'd have something
 like this
 
 function()
 {
 loop1()
 {
 [...]
 }
 }

 I really dislike that the end of loop2  is implicit rather than
 explicit. 

Since in the above languages indentation is optional but you still use it
(and even may use a program that provides the correct indentation if the
coder didn't do it), what prevents you from adding optional end-markers in
Python? They are not required, but they are not forbidden either, very
similar to the indenting in the above languages. Something like this:

function()
loop1()
blah
blah

loop2()
blah

loop3()
blah
#end loop3()

blah3
#end loop2()
#end loop1()

otherloop()
blah
#end otherloop()
#end function()

Of course, few people will write like this, but it probably is easier to
write a Python code formatter that adds them than it is to write a C code
formatter that adds proper indentation and provides your preferred
placement of braces.

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Terry Reedy

Stephen Kellett [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 To answer your first question: In C++/Ruby/Pascal you'd have something
 like this

 function()
 {
loop1()
{
blah
blah

loop2()
{
blah

loop3()
{
blah
}

blah
}
}

otherloop()
{
blah
}
 }

 and in Python that gets to

 function()
loop1()
blah
blah

loop2()
blah

loop3()
blah

blah3

otherloop()
blah

Much nicer, IMHO ;-).

 I really dislike that the end of loop2  is implicit rather than
 explicit. If its implicit you have to look for it. And if blah3 didn't
 exist then both loop2 and loop3 would be ending implicitly.

So add one of those judicious, informative comments that some have written 
about in this thread ;-)
  # end loop2
where 'loop2' would typically be something like 'i loop'.  If blah3 didn't 
exist, you could add
# end loop3
*above* the end loop2 comment.

I personally found matching far-apart well-indented braces visually 
something of a nuisance too, so I sometimes did much the same in C:
  } /* end i loop */

 This problem gets worse with longer functions and more indentation.

And devoting lines to braces, including those that are visually interfering 
(such as those for loop3) expands blocks and  makes it more likely that 
blocks will span screens.  This makes the problem worse.

  I'm sure some  people are thinking the above is elegant.

Yes, allowing programmers to add explict end-suite markers only where 
needed is, to me, more elegant that forcing redundant begin-suite markers 
and often unneeded end-markers.

Terry Jan Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Gerhard Fiedler
On 2006-08-10 06:44:04, Stephen Kellett wrote:

 Just found this on c.l.ruby. Seems kind of relevant.

 http://www.americanscientist.org/template/AssetDetail/assetid/51982
 
 The Semicolon Wars

Good reading :) Thanks.

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Bruno Desthuilliers
Stephen Kellett wrote:
 In message [EMAIL PROTECTED], Carl
 Banks [EMAIL PROTECTED] writes
 Stephen Kellett wrote:
 I don't really understand how a closing brace helps here.  Care to
 explain why it helps you?
 
 (Deeply nested long functions are evil anyways.  If you have such a
 
 I didn't write deeply nested. I wrote multiple levels of indentation.
 They are not the same thing (they can be, but they don't have to be). A
 lot of code gets to 3 or 4 levels of indentation quite easily. I
 wouldn't call that deeply nested, not by a long shot.
 
 To answer your first question: In C++/Ruby/Pascal you'd have something
 like this
 
 function()
 {
 loop1()
 {
 blah
 blah
 
 loop2()
 {
 blah
 
 loop3()
 {
 blah
 }
 
 blah
 }
 }
 
 otherloop()
 {
 blah
 }
 }
 
 and in Python that gets to
 
 function()
 loop1()
 blah
 blah
 
 loop2()
 blah
 
 loop3()
 blah
 
 blah3
 
 otherloop()
 blah
 
 I really dislike that the end of loop2  is implicit rather than
 explicit. 

nitpicking
Well, one can argue that since Python grammar defines that a code block
ends with the first following non-blank line that one indentation level
less, it's perfectly explicit !-)
/nitpicking

But practically speaking :
 If its implicit you have to look for it. 

Indeed. And yes, I agree that it's not that good wrt/ readability for
any complex or long block.

OTOH, nothing prevents you to add a # end block comment where
appropriate - FWIW, I used to do it in C after the closing brace for any
lengthy block (and code blocks tend to be longer in C than in Python).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Georg Brandl
Gerhard Fiedler wrote:

 function()
 loop1()
 blah
 blah
 
 loop2()
 blah
 
 loop3()
 blah
 #end loop3()
 
 blah3
 #end loop2()
 #end loop1()
 
 otherloop()
 blah
 #end otherloop()
 #end function()
 
 Of course, few people will write like this, but it probably is easier to
 write a Python code formatter that adds them than it is to write a C code
 formatter that adds proper indentation and provides your preferred
 placement of braces.

It's already there: Tools/scripts/pindent.py.

Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-10 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
Gerhard Fiedler [EMAIL PROTECTED] writes
 http://www.americanscientist.org/template/AssetDetail/assetid/51982

 The Semicolon Wars

Good reading :) Thanks.

Found something else relevant to this thread. The Pliant language. 
Appears to use whitespace indentation for grouping.

http://fullpliant.org/pliant/language/parser/default_syntax.html

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Slawomir Nowaczyk
On Mon, 07 Aug 2006 16:47:57 -0700
Jason [EMAIL PROTECTED] wrote:

# It is annoying that certain communication channels do not respect
# white-space.  I dislike using braces because I have to indicate my
# intentions twice: once for the compiler and once for humans.

I must admit I do not get this indicate intentions twice argument,
even though I heard it a number of times now... It's not that braces
require more work or more typing or something, after all -- at least
not if one is using a decent editor.

Really, typing brace after function/if/etc should add newlines and
indent code as required -- automatically. Actually, for me, it is even
*less* typing in C and similar languages... I probably should teach my
Emacs to automatically add newline after colon in Python, just as it
does after a brace in C... As soon as I figure out how to deal with
dictionary literals. Hmmm.

-- 
 Best wishes,
   Slawomir Nowaczyk
 ( [EMAIL PROTECTED] )

Be strict when sending and tolerant when receiving.
 RFC 1958 - Architectural Principles of the Internet - section 3.9

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread [EMAIL PROTECTED]
Slawomir Nowaczyk wrote:

 I must admit I do not get this indicate intentions twice argument,
 even though I heard it a number of times now... It's not that braces
 require more work or more typing or something, after all -- at least
 not if one is using a decent editor.

Its not the typing, its the fact that when you say the same thing
twice, there is the potential for them to get out of sync.  If the
method the compiler uses (braces) and the method the human uses
(indentation) to determine what the code does don't agree, then a
reader will be likely to misunderstand what it will actually do.  One
of the driving principles behind Python is that, because code will be
read more often than written, readability is more important.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Pierre Barbier de Reuille
Carl Banks wrote:
 Michiel Sikma wrote:
 Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven:

 As others have pointed out, these people really do exist, and they
 each believe their preconception -- that significant whitespace is
 intrinsically wrong -- is valid, and automatically makes Python a
 lesser language.
 Well, I most certainly disagree with that, of course, but you gotta
 admit that there's something really charming about running an auto-
 formatting script on a large piece of C code, turning it from an
 unreadable mess into a beautifully indented and organized document.
 
 The only time I get that satisfaction is when I run the formatter to
 format some C code I'm asked to debug.  Quite often the problem was
 something that could have been easily spotted if the coder had used
 good indentation in the first place.  Though they probably wouldn't
 have seen it anyways, considering the poor programming skills of most
 engineers (the classical definition, not computer engineers).
 
 The very fact the code formatters exist should tell you that grouping
 by indentation is superior.
 
 
 Carl Banks
 

Problem being : grouping by indentation do *not* imply good indentation.
For example, I had to read a piece of (almost working) code which looked
like that :


  if cond1 : stmt1
 stmt2
 stmt3
  if cond2:  stmt4
 stmt5
  elif cond3:stmt6
 stmt7
  else:  stmt8
 stmt9
 stmt10
 stmt11



So you can tell what you want, but this code is valid but impossible to
read and impossible to reindent correctly. So although I personnaly like
Python, I still don't think meaningful indentation is good.

Pierre
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Jean-Paul Calderone
On Wed, 09 Aug 2006 13:47:03 +0100, Pierre Barbier de Reuille [EMAIL 
PROTECTED] wrote:
Carl Banks wrote:
 Michiel Sikma wrote:
 Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven:

 As others have pointed out, these people really do exist, and they
 each believe their preconception -- that significant whitespace is
 intrinsically wrong -- is valid, and automatically makes Python a
 lesser language.
 Well, I most certainly disagree with that, of course, but you gotta
 admit that there's something really charming about running an auto-
 formatting script on a large piece of C code, turning it from an
 unreadable mess into a beautifully indented and organized document.

 The only time I get that satisfaction is when I run the formatter to
 format some C code I'm asked to debug.  Quite often the problem was
 something that could have been easily spotted if the coder had used
 good indentation in the first place.  Though they probably wouldn't
 have seen it anyways, considering the poor programming skills of most
 engineers (the classical definition, not computer engineers).

 The very fact the code formatters exist should tell you that grouping
 by indentation is superior.


 Carl Banks


Problem being : grouping by indentation do *not* imply good indentation.
For example, I had to read a piece of (almost working) code which looked
like that :


  if cond1 : stmt1
 stmt2
 stmt3
  if cond2:  stmt4
 stmt5
  elif cond3:stmt6
 stmt7
  else:  stmt8
 stmt9
 stmt10
 stmt11


This isn't actually legal Python.  Each branch starts with a simple suite and 
then proceeds to try to have a full suite as well.  A block can consist of one 
or the other, but not both.  Additionally, the nested if/elif has the wrong 
indentation and fits into no suite.

The closest legal example I can think of is:

  if cond1 :
 stmt2
 stmt3
 if cond2:
stmt5
 elif cond3:
stmt7
  else:
 stmt9
 stmt10
 stmt11

Which, while ugly, actually makes it much clearer what is going on.


So you can tell what you want, but this code is valid but impossible to
read and impossible to reindent correctly. So although I personnaly like
Python, I still don't think meaningful indentation is good.

If your example were actually valid (which it isn't), all it would
demonstrate is that Python should be even stricter about indentation,
since it would have meant that there is still some whitespace which
has no meaning and therefore can be adjusted in meaingless ways by
each programmer, resulting in unreadable junk.

Jean-Paul
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Brett g Porter
[EMAIL PROTECTED] wrote:
 Its not the typing, its the fact that when you say the same thing
 twice, there is the potential for them to get out of sync.  If the
 method the compiler uses (braces) and the method the human uses
 (indentation) to determine what the code does don't agree, then a
 reader will be likely to misunderstand what it will actually do.  One
 of the driving principles behind Python is that, because code will be
 read more often than written, readability is more important.

Not to mention the errors that creep in when code is maintained, like 
when C code starting out as

if (i  SOME_CONSTANT)
doSomething();

gets maintained to

if (i  SOME_CONSTANT)
doSomething();
doSomethingDangerous();

without the programmer adding the surrounding braces. The programmer's 
intent is clear to me as a human, but the C compiler will disagree with 
me, and in this case, the compiler will be right and I'm wrong.

You can (and we do, at my company) have coding standards that mandate 
braces around single line if()s in C/C++, but that's really just 
patching around the problem (and it counts on humans being consistent).

Pushing the scutwork down onto tools is not as good a solution as 
eliminating the scutwork, especially when it shouldn't be necessary at 
all...




-- 
// Brett g Porter * [EMAIL PROTECTED]
// http://www.bgporter.net/blog
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
[EMAIL PROTECTED] [EMAIL PROTECTED] writes
of the driving principles behind Python is that, because code will be
read more often than written, readability is more important.

In which case, for long functions with multiple levels of indentation 
Python fails compared to languages that use braces or END or end; etc.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread skip

 of the driving principles behind Python is that, because code will be
 read more often than written, readability is more important.

Stephen In which case, for long functions with multiple levels of
Stephen indentation Python fails compared to languages that use braces
Stephen or END or end; etc.

No.  In that case Python makes it more readily apparent that your code is
too complex.  With C, Java, C++, Perl or FORTRAN you just smush everything
over to the left and pretend it's not. ;-)

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
Gerhard Fiedler [EMAIL PROTECTED] writes
But there is well-written code that is as much as reasonably possible
self-documenting, meaning easy to read and understand, with a clear
structure, helpful names, appropriate types (where applicable) etc etc.

But that code is documenting what is does, not what it should do.
That is the fallacy of self-documenting. It is simply a bogus concept. 
If you have the two together then if they match, most likely the program 
is written correctly. If you have only the one you can't make the 
comparison.

I don't think you should have a line of comment per line of code. I once 
worked in a place where they insisted on 1 comment per 5 lines of code. 
I was the #1 troublemaker there after they created that rule - I hated 
it. It resulted in a lot of bogus comments that added nothing. Its what 
you write and where. The problem with the self-documenting crowd is they 
don't write anything so you can't follow their assumptions in the 
comments.

It should be as sparse as you can get but enough so that each 
block/chunk of code can be validated by comparing it with the comment 
that describes what you are doing.

My first code was basic on a VIC-20, then assembly on a variety of 
different 6502/6510 based machines (C64, C16, Atari...). I didn't bother 
much with comments back then. I was writing games and once they are done 
you never revisit them so you didn't care too much as long as you got 
the job done. I thought it was reasonably obvious what each function did 
etc. Ding! I went back some years later and looked at some of my own 
code. I had little idea what a lot of it did. I started commenting my 
code after that. So when it came time to port a game written for the 
6510/6516/6502 to the 68000 (Atari ST) and IBM PC-AT (80286) the 
comments came in handy. Sadly the game never saw the light of day for 
legal reasons outside of my control. The game was a copy of the 
wonderful arcade game Dingo written by Ashbury Computers and Graphics 
(the team that later became Ultimate Play the Game who wrote for the 
Sinclair ZX Spectrum very successfully in the 1980s). A bit of history 
for you :-)

Since someone mentioned assemblers and significant whitespace and I'm 
rambling about assembly: I don't every remember whitespace being 
significant for any of the assemblers I used (650x, 630x, 680x, 8085, 
80286, 68000). There was a convention though - you indented to column 8 
to write the mnemonics and used the first 6 or 7 chars for labels for 
branch/jmp instructions.

Come on, if you have been in the business for 23 years you know what I
mean.

If you mean, should code be well written, thought about, well formatted, 
sensible class/variable names, redesigned if you find a better way, sure 
no problem with that.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Slawomir Nowaczyk
On Wed, 09 Aug 2006 05:00:20 -0700
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

# Slawomir Nowaczyk wrote:
# 
#  I must admit I do not get this indicate intentions twice argument,
#  even though I heard it a number of times now... It's not that braces
#  require more work or more typing or something, after all -- at least
#  not if one is using a decent editor.
# 
# Its not the typing, its the fact that when you say the same thing
# twice, there is the potential for them to get out of sync.  

Which, in my book, is the *right* thing... if I see a wrongly indented
piece of code, that's a good sign that it needs to be checked. It's
the same principle as in if documentation and code disagree, both are
probably wrong.

YMMV, of course.

# If the method the compiler uses (braces) and the method the human
# uses (indentation) to determine what the code does don't agree,
# then a reader will be likely to misunderstand what it will actually
# do.

Well, not in my experience. In my experience, such discrepancies
usually only show up in places where something bad happens anyway.

# One of the driving principles behind Python is that, because code
# will be read more often than written, readability is more
# important.

That's exactly my point :)

-- 
 Best wishes,
   Slawomir Nowaczyk
 ( [EMAIL PROTECTED] )

Today advance is so rapid that even the astronauts who set foot on the
moon in 1969 had never seen a digital watch

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Slawomir Nowaczyk
On Wed, 09 Aug 2006 09:13:21 -0500
[EMAIL PROTECTED] wrote:

# 
#  of the driving principles behind Python is that, because code will be
#  read more often than written, readability is more important.
# 
# Stephen In which case, for long functions with multiple levels of
# Stephen indentation Python fails compared to languages that use braces
# Stephen or END or end; etc.
# 
# No.  In that case Python makes it more readily apparent that your code is
# too complex.  With C, Java, C++, Perl or FORTRAN you just smush everything
# over to the left and pretend it's not. ;-)

Well, one space is sufficient indentations for Python, right? So even
on 80 column screen, you can easily fit about 40 levels of nesting
before it becomes a real problem :D

In other words, it is possible to write bad code in any language. We
should focus on making it easier to write good code, not to make
writing bad code difficult.

-- 
 Best wishes,
   Slawomir Nowaczyk
 ( [EMAIL PROTECTED] )

The nice thing about standards is that there are so
many of them to choose from.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Carl Banks
Stephen Kellett wrote:
 In message [EMAIL PROTECTED],
 [EMAIL PROTECTED] [EMAIL PROTECTED] writes
 of the driving principles behind Python is that, because code will be
 read more often than written, readability is more important.

 In which case, for long functions with multiple levels of indentation
 Python fails compared to languages that use braces or END or end; etc.

I don't really understand how a closing brace helps here.  Care to
explain why it helps you?

(Deeply nested long functions are evil anyways.  If you have such a
function then you have bigger problems than minor defects in
readability. :)


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread skip

Slawomir # No.  In that case Python makes it more readily apparent
Slawomir # that your code is too complex.  With C, Java, C++, Perl or
Slawomir # FORTRAN you just smush everything over to the left and
Slawomir # pretend it's not. ;-)

Slawomir Well, one space is sufficient indentations for Python, right? So 
even
Slawomir on 80 column screen, you can easily fit about 40 levels of nesting
Slawomir before it becomes a real problem :D

Oh, sure.  Hence the smiley in my post...

Smileys all around.  I'm happy.

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Rob Wolfe

Slawomir Nowaczyk wrote:

 Really, typing brace after function/if/etc should add newlines and
 indent code as required -- automatically. Actually, for me, it is even
 *less* typing in C and similar languages... I probably should teach my
 Emacs to automatically add newline after colon in Python, just as it
 does after a brace in C... As soon as I figure out how to deal with
 dictionary literals. Hmmm.

Are you sure? My Emacs already know how to do it with the help
of python-mode and magic function py-newline-and-indent.

emacs-version 21.3.1
py-version $Revision: 4.63 $

Regards,
Rob

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Carl Banks
Pierre Barbier de Reuille wrote:
 Problem being : grouping by indentation do *not* imply good indentation.

By itself, it doesn't.  But with grouping by indentation, bad
indentation no longer results from mere carelessness, which is no small
thing.

Although Python doesn't do this, it is possible to mandate a specific
indent (4 spaces, say), or at least a reasonable consistent indent,
which would indeed all but guarantee good indenting.  (I say all but
only to account for deliberately misleading code, perhaps using clever
line breaks and comments.)


 For example, I had to read a piece of (almost working) code which looked
 like that :

   if cond1 : stmt1
  stmt2
  stmt3
   if cond2:  stmt4
  stmt5
   elif cond3:stmt6
  stmt7
   else:  stmt8
  stmt9
  stmt10
  stmt11

 So you can tell what you want, but this code is valid but impossible to
 read and impossible to reindent correctly. So although I personnaly like
 Python, I still don't think meaningful indentation is good.

Even if this were legal code (it isn't), it's still more transparent
than some of the C code I've seen.


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Michiel Sikma

Op 9-aug-2006, om 16:48 heeft Carl Banks het volgende geschreven:

 Even if this were legal code (it isn't), it's still more transparent
 than some of the C code I've seen.


 Carl Banks

Still kind of too bad that means there won't ever be an International  
Obfuscated Python Code Contest.

#define _ -F00||--F-OO--;
int F=00,OO=00;main(){F_OO();printf(%1.3f\n,4.*-F/OO/OO);}F_OO()
{
 _-_-_-_
_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_
 _-_-_-_
}

:)

Michiel

(source: http://www0.us.ioccc.org/years.html#1988)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Ed Jensen
infidel [EMAIL PROTECTED] wrote:
 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.
 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

I like Python, but I do wish it used braces instead, if only because
every editor I'm likely to use supports brace matching, which makes it
easy to (for example) jump to the bottom or top of a block.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Carl Banks
Michiel Sikma wrote:
 Op 9-aug-2006, om 16:48 heeft Carl Banks het volgende geschreven:

  Even if this were legal code (it isn't), it's still more transparent
  than some of the C code I've seen.
 
  Carl Banks

 Still kind of too bad that means there won't ever be an International
 Obfuscated Python Code Contest.

 #define _ -F00||--F-OO--;
 int F=00,OO=00;main(){F_OO();printf(%1.3f\n,4.*-F/OO/OO);}F_OO()
 {
  _-_-_-_
 _-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
   _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_
  _-_-_-_
 }

 :)

 Michiel

 (source: http://www0.us.ioccc.org/years.html#1988)

*yawn*   ;)


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Gerhard Fiedler
On 2006-08-09 11:10:20, Stephen Kellett wrote:

 If you mean, should code be well written, thought about, well formatted, 
 sensible class/variable names, redesigned if you find a better way, sure 
 no problem with that.

I mean the code should be written so that as few as possible comments are
necessary to understand it. I don't mean that additional comments are a bad
thing.

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-09 Thread Tim Roberts
Dennis Lee Bieber [EMAIL PROTECTED] wrote:

   I forget what COBOL used, but it had a few fields of its own.

Not in fixed columns.  Surprisingly, layout in COBOL was more closely
related to Python, in that indentation was significant, but the number of
characters per indent was up to the programmer.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Michiel Sikma

Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven:

 As others have pointed out, these people really do exist, and they
 each believe their preconception -- that significant whitespace is
 intrinsically wrong -- is valid, and automatically makes Python a
 lesser language.

Well, I most certainly disagree with that, of course, but you gotta  
admit that there's something really charming about running an auto- 
formatting script on a large piece of C code, turning it from an  
unreadable mess into a beautifully indented and organized document. I  
actually sometimes intentionally programmed ugly code so that I could  
do that. I kind of miss it. :)

Michiel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Bruno Desthuilliers
infidel wrote:
 Where are they-who-hate-us-for-our-whitespace?  

You may find some on comp.lang.ruby...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread gslindstrom
infidel wrote:
 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.
 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

Some of it may be a reaction from old-timers who remember FORTRAN,
where (if memory serves), code had to start in column 16 and code
continutations had to be an asterik in column 72 (it's been many years
since I've done any work in FORTRAN, but you get the idea)

Or it may be a reaction from Assembler, which is also quite
column-centric (is Assembler still taught in schools??).

But most likely, it's different.  It's easier to complain about things
than to actually check them out.  Recently I had a friend tell me that
they absolutely hated a certain tv personality/author.  When I asked if
they had ever watched the person or read one of their books, they said
Why should I?  I hate them!!.  I think the same attitude comes into
play with computer languages.

One more thing.  I have many friends that love to program Perl.
Without bashing the language, I find it ironic when they say There's
more than one way to do it but inisit that I should be using Perl
while they quote Python as There's only one way to do it though
(most) Python coders I know are fairly comforatble dealing with
multiple languages.

--greg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread infidel
 One of the most stupid language-definition decisions that most people
 have come across is the Makefile format.

snippage/

 Hope that goes some way to explaining one possible reason why rational
 people can consistently react in horror to the issue.

Ah, thanks for that.  This peek into history makes the irrational fear
of significant whitespace seem a little less irrational.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread infidel
 All societies demonise outsiders to some extent. It's an unfortunate
 human (and animal) trait.

Which is why I questioned it.

 So just block your ears when the propaganda vans with the loud-speakers
 on top drive past your dwelling :-)

Funny how using python makes me feel like a member of some kind of
rebellion against the empire.  Where I work it's all VB, VB.NET, and
ASP.NET.  I've been the lone voice in the wilderness for so long that
I've become an inside joke.  I actually have a certificate that says
Most likely to re-write the system in Python.

*sigh*

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Thomas Guettler
Am Mon, 07 Aug 2006 14:43:04 -0700 schrieb infidel:

 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.
 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

I like python, but sometimes i don't like that python allows
spaces and tabs. It would be easier if you had less choice and
must use four spaces.

That's one small argument against the current whitespace syntax in python.

 Thomas



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Alex Martelli
[EMAIL PROTECTED] wrote:

 infidel wrote:
  Where are they-who-hate-us-for-our-whitespace?  Are they really that
  stupid/petty?  Are they really out there at all?  They almost sound
  like a mythical caste of tasteless heathens that we have invented.
  It just sounds like so much trivial nitpickery that it's hard to
  believe it's as common as we've come to believe.
 
 Some of it may be a reaction from old-timers who remember FORTRAN,
 where (if memory serves), code had to start in column 16 and code
 continutations had to be an asterik in column 72 (it's been many years
 since I've done any work in FORTRAN, but you get the idea)

Column 7 was the start, 6 the one for continuation; 1-5 and 73-80 were
ignored by the compiler and could be used for numbering, grouping c.
Been many years in my case, too, but as I was a mainly-Fortran guru for
several years in my career, it's hard to forget;-).

 Or it may be a reaction from Assembler, which is also quite
 column-centric (is Assembler still taught in schools??).

I never used a column-centric Assembler: even the first assemblers I
used, in the '70s (6502, Z80, a mini called HP1000, VAX/VMS when it was
just out, BAL/370, ...) were all column-indifferent.  The HP1000 did not
even have a punched-card reader: it used punched _tape_ instead (quite a
popular device then, as it came with teletypes typically used as
consoles), so keeping track of columns would have a royal mess:-).

I'm pretty sure you're still _able_ to take SOME Assembler-based course
in most universities, but you need to strive pretty hard for the
purpose... it's definitely not in the default curriculum, even for
EEs, much less CSs.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Aahz
In article [EMAIL PROTECTED],
infidel [EMAIL PROTECTED] wrote:

Where are they-who-hate-us-for-our-whitespace?  Are they really that
stupid/petty?  Are they really out there at all?  They almost sound
like a mythical caste of tasteless heathens that we have invented.
It just sounds like so much trivial nitpickery that it's hard to
believe it's as common as we've come to believe.

When I put on my Python evangelist hat, I do get complaints about that
regularly.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.  --Brian W. Kernighan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Andy Dingley

Thomas Guettler wrote:

 I like python, but sometimes i don't like that python allows
 spaces and tabs. It would be easier if you had less choice and
 must use four spaces.

That's the nice thing about Python. It doesn't care about indentation
distance, it just wants some and consistent.

I like the idea that humans see the whitespace as significant anyway,
so document the fact and use it  (I presume this came from Occam).
What I don't like so much is that the _ends_ of blocks are less
visually obvious.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Gerhard Fiedler
On 2006-08-08 12:49:35, Aahz wrote:

Where are they-who-hate-us-for-our-whitespace?  Are they really that
stupid/petty?  Are they really out there at all?  They almost sound
like a mythical caste of tasteless heathens that we have invented.
It just sounds like so much trivial nitpickery that it's hard to
believe it's as common as we've come to believe.
 
 When I put on my Python evangelist hat, I do get complaints about that
 regularly.

Being new to Python, and the indenting thing being the one feature that
convinced me to take a serious look at Python, there's almost only one
conclusion for me: they must not like self-documenting code... :)

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Stephen Kellett
In message [EMAIL PROTECTED], 
Gerhard Fiedler [EMAIL PROTECTED] writes
conclusion for me: they must not like self-documenting code... :)

Oh dear. So if the code is wrong it is self documenting?

Comments document what the code should do.
The code shows what the code actually does.

Also from a maintenance perspective reading comments is a lot faster 
than reading the code. For a whitespace significant language this can be 
very helpful when the formatting gets mangled for some reason.

There is no such thing as self-documenting code.

People that say they don't need to document their code because its self 
documenting - no hire. I've been writing and selling software for 23 
years now and I still keep hearing this bull about self documenting 
code. Sigh.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Carl Banks
Michiel Sikma wrote:
 Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven:

  As others have pointed out, these people really do exist, and they
  each believe their preconception -- that significant whitespace is
  intrinsically wrong -- is valid, and automatically makes Python a
  lesser language.

 Well, I most certainly disagree with that, of course, but you gotta
 admit that there's something really charming about running an auto-
 formatting script on a large piece of C code, turning it from an
 unreadable mess into a beautifully indented and organized document.

The only time I get that satisfaction is when I run the formatter to
format some C code I'm asked to debug.  Quite often the problem was
something that could have been easily spotted if the coder had used
good indentation in the first place.  Though they probably wouldn't
have seen it anyways, considering the poor programming skills of most
engineers (the classical definition, not computer engineers).

The very fact the code formatters exist should tell you that grouping
by indentation is superior.


Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-08 Thread Gerhard Fiedler
On 2006-08-08 19:02:27, Stephen Kellett wrote:

 In message [EMAIL PROTECTED], 
 Gerhard Fiedler [EMAIL PROTECTED] writes
conclusion for me: they must not like self-documenting code... :)
 
 Oh dear. So if the code is wrong it is self documenting?

?? I'm not sure you are actually responding to what I wrote. I did not make
any affirmation about a relationship between correctness of code and its
self-documenting properties.


 Comments document what the code should do.
 The code shows what the code actually does.

That's only in theory like this, and then only in a bad theory. I'm sure in
23 years you have seen as many code comments as I have that documented what
a previous version of the code should have done...

 Also from a maintenance perspective reading comments is a lot faster than
 reading the code. 

This depends a lot on the code, the comments and the reader. I prefer code
that reads as fast or faster than inline comments and coders that read code
as fast as comments :)

(I'm not talking about useful header comments. But even these can be made a
lot more succinct through appropriate coding.)

 There is no such thing as self-documenting code.

But there is well-written code that is as much as reasonably possible
self-documenting, meaning easy to read and understand, with a clear
structure, helpful names, appropriate types (where applicable) etc etc.
Come on, if you have been in the business for 23 years you know what I
mean. 

Self-documenting -- as used by me -- is always meant as a goal to be
approached gradually, not a state where you are or not; as much as
possible is always implied, the question is more or less not whether or
not. I thought that was somehow obvious... :)


 People that say they don't need to document their code because its self 
 documenting - no hire. 

People that need a line of comment for every line of code -- no hire either
:)  It's the right balance. 

This is not really a subject for quick shots. And it is utterly off-topic
for my post.

Here's the long version of what I wrote:

Python's indent-based code structure is more self-documenting than for
example the brace-based structure of C in the following way. In C, it is
common practice to document the code structure by indenting. Indenting in C
is mere /documentation/ -- it is not required for the code to work as
written, but it is required (or commonly considered required) to document
its structure. When done properly, it's part of the self-documentation of
C code: you don't write a bunch of white space-stripped C and then document
the structure of that blob; you document the structure in the code by
correctly indenting it. However, it is easy to write C code where the
indenting and the structure are out of sync. (I know that there are tools
for that, but still...) In Python, the indenting is not a documentation
convention dissociated from the code structure, it /is/ the code structure.
In that sense, Python code is more self-documenting than C.

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


do people really complain about significant whitespace?

2006-08-07 Thread infidel
Where are they-who-hate-us-for-our-whitespace?  Are they really that
stupid/petty?  Are they really out there at all?  They almost sound
like a mythical caste of tasteless heathens that we have invented.
It just sounds like so much trivial nitpickery that it's hard to
believe it's as common as we've come to believe.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread Jason
infidel wrote:
 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.
 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

I have a coworker who dislikes Python for the whitespace.  He likes the
idea that if someone is silly enough to put a whole program on one
line, they can put it back together by following the braces.  He also
likes that the compiler can compile the program even if a normal person
can't read it.

I've pointed out that we format our code with the whitespace anyway.
He points out that if some code gets accidentally dedented, it is
difficult for another programmer to determine which lines were supposed
to be in the indented block.  I pointed out that if someone
accidentally moves a curly brace, the same problem can occur.
Anecdotally, I've never had either problem.

Sadly, people who do dislike the whitespace do exist.  I have also
talked with several other programmers who were very turned off about
the white-space thing and wouldn't give the language a chance.

Eric S. Raymond wrote enthusiastically about Python, but was initially
turned off by the whitespace rules.  (See
http://www.python.org/about/success/esr/; for details.)

I personally love that my logically formatted code imparts information
logically to the language.

(I haven't seen a good hate-us-for-our-whitespace thread go on for
awhile.  I do remember some good We like Python, Now Add Our Favorite
C/C++/LISP/INTERCAL Features or We'll Leave threads on this newsgroup.)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread crystalattice
infidel wrote:
 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.
 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

Actually, some of the guys I work with complained about Python when
they first had to learn it for our Zope server.  One of them is an
old-school Unix guy who spent the last 20+ years doing procedural
languages with funky syntax, like C.  The other one is a VB.NET junkie
who I don't think has much experience outside of MS languages, except
maybe Java.

One of the complaints they had for the first few weeks was the white
space issue and the fact Python doesn't have brackets or semicolons.
Obviously they learned to deal with it but they sure made it seem
like it was a painful transition.  I think the biggest pain was the
fact that they are forced to indent their code now so they can't be
lazy anymore.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread John Machin

infidel wrote:
 Where are they-who-hate-us-for-our-whitespace?  Are they really that
 stupid/petty?  Are they really out there at all?  They almost sound
 like a mythical caste of tasteless heathens that we have invented.

All societies demonise outsiders to some extent. It's an unfortunate
human (and animal) trait. In some societies, this is directed from the
top. Very fortunately, this is AFAICT not the case in the Python
community.

 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

So just block your ears when the propaganda vans with the loud-speakers
on top drive past your dwelling :-)

...

However, meaninglessly significant whitespace at the *other* end of a
line can be annoying:

# a = \
... 1
# a
1
# b = \
  File stdin, line 1
b = \
 ^
SyntaxError: invalid token

Huh? Can't see what the problem is? Maybe this exaggerated example may
help:

# c = \
  File stdin, line 1
c = \
  ^
SyntaxError: invalid token

Cheers,
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread bearophileHUGS
Jason wrote:
 He points out that if some code gets accidentally dedented, it is
 difficult for another programmer to determine which lines were supposed
 to be in the indented block.  I pointed out that if someone
 accidentally moves a curly brace, the same problem can occur.

I like significant whitespace, but a forum, newsgroup manager (like
Google Groups in the beginning), email management program, blog comment
system, etc, may strip leading whitespace, and it usually doesn't
move braces. A language (like Python) doesn't exist alone in vacuum,
it exists in an ecosystem of many other programs/systems, and if they
don't manage leading whitespace well, such language may have some
problems :-)

Bye,
bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread Ben Finney
infidel [EMAIL PROTECTED] writes:

 It just sounds like so much trivial nitpickery that it's hard to
 believe it's as common as we've come to believe.

As others have pointed out, these people really do exist, and they
each believe their preconception -- that significant whitespace is
intrinsically wrong -- is valid, and automatically makes Python a
lesser language.

One of the most stupid language-definition decisions that most people
have come across is the Makefile format. If you're not familiar with
it, spaces and tabs are *each* significant. Specifically, putting
spaces where a tab is required will result in a file that, while it
may be visually identical to a correctly formatted file, doesn't parse
correctly. In hindsight it's trivial to predict the needlessly painful
learning process that ensues.

This is a very painful memory for many programmers, and the general
opinion that results is syntactically significant whitespace is
bad. This is the phrase that always gets brought out, and it's often
clear that the person hasn't considered *why* it's bad.

The issue with the Makefile format (lampooned wonderfully by the
Whitespace programming language) is that *invisible* differences in
whitespace should not be significant. In a Makefile, you *must* mix
spaces and tabs in the same file; this leaves the door wide open to
invisible differences. In Python, an admonishment of always indent
each file consistently suffices.

Hope that goes some way to explaining one possible reason why rational
people can consistently react in horror to the issue.

-- 
 \  Friendship is born at that moment when one person says to |
  `\  another, 'What! You too? I thought I was the only one!'  -- |
_o__)   C.S. Lewis |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread Jason
[EMAIL PROTECTED] wrote:
 Jason wrote:
  He points out that if some code gets accidentally dedented, it is
  difficult for another programmer to determine which lines were supposed
  to be in the indented block.  I pointed out that if someone
  accidentally moves a curly brace, the same problem can occur.

 I like significant whitespace, but a forum, newsgroup manager (like
 Google Groups in the beginning), email management program, blog comment
 system, etc, may strip leading whitespace, and it usually doesn't
 move braces. A language (like Python) doesn't exist alone in vacuum,
 it exists in an ecosystem of many other programs/systems, and if they
 don't manage leading whitespace well, such language may have some
 problems :-)

 Bye,
 bearophile

Certainly, you are correct.  Most of the time, I zip up any source code
for email purposes.  But newsgroup managers are certainly an issue.
For comment thingies online, the preformat tag is your friend, too.

It is annoying that certain communication channels do not respect
white-space.  I dislike using braces because I have to indicate my
intentions twice: once for the compiler and once for humans.

In the situations where I use Python, though, I haven't had a problem.
In the situations where my coworker is using Python (code updates
through CVS), he also shouldn't have a problem.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread bearophileHUGS
Jason wrote:
 But newsgroup managers are certainly an issue.
 For comment thingies online, the preformat tag is your friend, too.

Time ago I used to add a | or something similar at the beginning of
lines, to avoid the leading whitespace stripping done by Google Groups.
Other (silly) solutions are to add explicitely the number of indents at
the beginning of a line (2 digits suffice), or to even add explicit
#end comments just under the dedents, so a script can read such ending
comments and reconstruct the original Python indentations... (lines
splitted with \ and similar require some extra care).

Bye,
bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: do people really complain about significant whitespace?

2006-08-07 Thread Jim
 He points out that if some code gets accidentally dedented, it is
 difficult for another programmer to determine which lines were supposed
 to be in the indented block.  I pointed out that if someone
 accidentally moves a curly brace, the same problem can occur.
 Anecdotally, I've never had either problem.

I have many times found that in moving a multi-screen block of code
from one place to another (where the indent is less or more) then I
have trouble re-indenting the code.  That is not to say that I don't in
the end prefer the significant whitespace, but I have had errors moving
code like:
  if ..
  try:
..
  except
..
  else ..
where it wound up (with the help of the emacs tab key) as
  if  ..
  try:
 ..
  except
 ..
  else ..
.  I attempt to be careful, but certainly it has happened to me.

Jim

-- 
http://mail.python.org/mailman/listinfo/python-list


Python with no significant whitespace

2005-01-25 Thread mep
Hi,all
Is there anybody trying to release a modification version to current
python source code with no significant whitespace, say replacing whitespace
by {}
like C or java. I do *NOT* mean whitespace is good or bad, just
want to know.

Best Regards,
mep


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python with no significant whitespace

2005-01-25 Thread Stephen Thorne
On Wed, 26 Jan 2005 11:31:18 +0800, mep [EMAIL PROTECTED] wrote:
 Hi,all
 Is there anybody trying to release a modification version to current
 python source code with no significant whitespace, say replacing whitespace
 by {}
 like C or java. I do *NOT* mean whitespace is good or bad, just
 want to know.

http://logix.livelogix.com/

don't know why you'd bother tho. any competant programmer already
indents code exactly like python requires you to.

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python with no significant whitespace

2005-01-25 Thread Tom
Just though I'd point out that Logix *does* use whitespace for
delimiting blocks. Or rather, it can use whitespace, and the languages
that come as standard do.

With Logix you could quite easily make a version of Python with, e.g.,
braces instead of whitespace for delimiting blocks. That's probably
what the Stephen was getting at.

Tom.

-- 
http://mail.python.org/mailman/listinfo/python-list