From: Dirck Blaskey 
Subject: colostomy
Date: Saturday, March 25, 2000 4:36 PM

After working with Python off and on for more than a year,
I really enjoy the language, and when I'm about to do
something always look at Python first to see if it fits.
Python seems to give me a lot of leverage.

That said, I have one suggestion (or maybe 'complaint').

Please, PLEASE make colon's optional when not needed.
After more than a year, I still frequently type this:
    if condition    # or def or while or for etc.
        do something

instead of
    if condition:
        do something

As long as the block isn't on the same line
( if condition: do something )
the colon isn't necessary, an end-of-line should be sufficient.

I waste a lot of time going back and filling in the bloody things.

After a quick look at the parser last year, I gave up on the idea that
fixing this would be a simple hack for me, but I think
it would be a simple hack for somebody closer to the code.

The only other suggestion I have, and this isn't nearly as important:
it would be nice to have block comments like c's /* */ to be
able to add a multi-line comment quickly outside of the
doc strings.

Thank you for your consideration

d

===========================
Dirck Blaskey
Danbala Software
dirck@danbala.com
http://www.danbala.com




From: Alex Subject: Re: colostomy Date: Saturday, March 25, 2000 4:49 PM Hi, Dirck. What editor do you use? I have something for emacs that automatically checks a python program for syntax errors, and moves the cursor to where they are happening. Let me know if you're interested, and I'll post it. It just occured to me that maybe with a small change it could safely fix the colon error you are talking about automatically, too. For the multiline comments, you can use triple-quoted strings even outside the docstrings. def example (): do_something () '''A multiline comment that is not part of a doc string.''' Alex.
From: Dirck Blaskey Subject: Re: colostomy Date: Saturday, March 25, 2000 10:07 PM Alex wrote in message news:etdityah7y8.fsf@w20-575-109.mit.edu... > ... > What editor do you use? I have something for emacs that automatically > checks a python program for syntax errors, and moves the cursor to where > they are happening. Let me know if you're interested, and I'll post it. I'm using Visual Slickedit (Win32/NT4) VS is programmable (I found Python syntax coloring for it, which is cool) but I don't know it well enough to program auto-completions (not sure if that is do-able, either) and I don't really like to use auto-completions. > For the multiline comments, you can use triple-quoted strings even > outside the docstrings. > > def example (): > do_something () > '''A multiline comment > that is not part of a doc string.''' Cool! I thought this was only allowed immediately at the top of a file or class or function before any other statements. This is very useful. thanks d =========================== Dirck Blaskey Danbala Software dirck@danbala.com http://www.danbala.com
From: Cliff Crawford Subject: Re: colostomy Date: Saturday, March 25, 2000 4:54 PM * Dirck Blaskey menulis: | | Please, PLEASE make colon's optional when not needed. | After more than a year, I still frequently type this: | if condition # or def or while or for etc. | do something | | instead of | if condition: | do something | | As long as the block isn't on the same line | ( if condition: do something ) | the colon isn't necessary, an end-of-line should be sufficient. I actually like the colons. They seem to make code a little easier to read. | I waste a lot of time going back and filling in the bloody things. After I learned Python, I had the same problem at first with C and semicolons. I'm not sure why I hate semicolons as EOL markers, but like colons as block markers; I guess one is too much redundancy while the other is just the right amount. | The only other suggestion I have, and this isn't nearly as important: | it would be nice to have block comments like c's /* */ to be | able to add a multi-line comment quickly outside of the | doc strings. You can enclose the comment in """...""". You can have strings anywhere where a statement is expected. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ icq 68165166 "IS I yes wardrobe yield [the] evaluation." member of A.H.M.A.D.
From: Dirck Blaskey Subject: Re: colostomy Date: Saturday, March 25, 2000 10:20 PM Cliff Crawford wrote in message news:slrn8dqo5c.4sd.cjc26@ith1-491.twcny.rr.com... > * Dirck Blaskey menulis: >>... >> Please, PLEASE make colon's optional when not needed. >> ... > I actually like the colons. They seem to make code a little easier > to read. I don't dispute their aesthetic value, but for me, in practice, the requirement gets in the way. I'm not exactly a new Python user either, I've written a fair amount of Python code. I just seem to have trouble sometimes teaching my hindbrain to remember things that my frontbrain forgets. (I HATE learning a new text editor.) I'm willing to bet I'm not the only coder who forgets to put them in on a regular basis. And since they're not really necessary, they should at least be optional. (The best approach for handling User Input errors isn't to provide a good error message, but to eliminate the possibility of error.) > >> I waste a lot of time going back and filling in the bloody things. > > After I learned Python, I had the same problem at first with C and > semicolons. I'm not sure why I hate semicolons as EOL markers, but > like colons as block markers; I guess one is too much redundancy > while the other is just the right amount. After many (10+) years of heavy (Heavy) C coding, I still would occasionaly forget to type in semi-colons - and now when typing Python I occasionaly add them in without thinking. Fortunately, Python is cool enough not to complain. >> The only other suggestion I have, and this isn't nearly as important: >> it would be nice to have block comments like c's /* */ ... > > You can enclose the comment in """...""". You can have strings > anywhere where a statement is expected. I hadn't known """ was allowed as a block comment - I had thought doc strings were the only block option. thanks for the tip, d =========================== Dirck Blaskey Danbala Software dirck@danbala.com http://www.danbala.com
From: Jason Stokes Subject: Re: colostomy Date: Saturday, March 25, 2000 10:38 PM Dirck Blaskey wrote in message ... >Cliff Crawford wrote in message >news:slrn8dqo5c.4sd.cjc26@ith1-491.twcny.rr.com... >> * Dirck Blaskey menulis: >>>... >>> Please, PLEASE make colon's optional when not needed. >>> ... >> I actually like the colons. They seem to make code a little easier >> to read. > >I don't dispute their aesthetic value, >but for me, in practice, the requirement gets in the way. The convention is easy enough to remember: as far as I've been able to make out, any statement that governs other statements (that is to say, indented underneath) ends with a colon. I've found it easy enough to adapt to, but perhaps I have fewer entrenched habits, being relatively new to programming.
From: Dirck Blaskey Subject: Re: colostomy Date: Saturday, March 25, 2000 11:08 PM Jason Stokes wrote in message news:FliD4.56740$3b6.225857@ozemail.com.au... > >> * Dirck Blaskey menulis: > >>>... > >>> Please, PLEASE make colon's optional when not needed. > >>> ... > ... > The convention is easy enough to remember: as far as I've been able to make > out, any statement that governs other statements (that is to say, indented > underneath) ends with a colon. > ... I guess I can only explain it like this: My head knows the syntax; my fingers don't. My fingers don't seem to learn very fast, either.
Subject: Re: colostomy Date: 03/26/2000 Author: Aahz Maruch In article , Dirck Blaskey wrote: > >I'm willing to bet I'm not the only coder who forgets to put them in on >a regular basis. And since they're not really necessary, they should >at least be optional. Guido is not a fan of deviance. -- --- Aahz (Copyright 2000 by aahz@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz
From: Subject: Re: colostomy Date: Tuesday, March 28, 2000 9:23 PM aahz@netcom.com (Aahz Maruch) wrote: > Dirck Blaskey wrote: > > > >I'm willing to bet I'm not the only coder who forgets to put them in on > >a regular basis. And since they're not really necessary, they should > >at least be optional. > > Guido is not a fan of deviance. > Is that 'deviance' or 'deviants'? :) Seriously, deviance from what? ... A long time ago I used a C compiler on the DEC VAX that would issue this warning message: "missing semi-colon, assumed." and Keep Compiling! It was pretty impressive, a compiler actually trying to be helpful. d (news.pacbell.net is otl) Sent via Deja.com http://www.deja.com/ Before you buy.
From: Grant Edwards Subject: Re: colostomy Date: Wednesday, March 29, 2000 8:13 AM In article <8bs410$qsg$1@nnrp1.deja.com>, dirckb@my-deja.com wrote: >Seriously, deviance from what? >A long time ago I used a C compiler on the DEC VAX that would >issue this warning message: "missing semi-colon, assumed." and >Keep Compiling! > >It was pretty impressive, a compiler actually trying to be >helpful. The problem is, they often seem to make the wrong guess when trying to be "helpful" and you just end up with a huge cascade of meaningless error and warning messages. Since it only takes a fraction of a second to recompile any of the source files I use, I don't see the advantage of trying to continue parsing code after the first few errors. I never fix more than the first one or two before re-compiling anyway -- a habit I developed while using "helpful" compilers. -- Grant Edwards grante Yow! You can't hurt at me!! I have an ASSUMABLE visi.com MORTGAGE!!
From: Moshe Zadka To: Cc: Subject: Re: colostomy Date: Tuesday, March 28, 2000 9:56 PM On Wed, 29 Mar 2000 dirckb@my-deja.com wrote: > A long time ago I used a C compiler on the DEC > VAX that would issue this warning message: > "missing semi-colon, assumed." > and Keep Compiling! That's exactly! what Guido hates, and I agree. How do you think we got in HTML hell? Precisely because browsers were trying to be helpful. TMTWODI just means you have to learn more then one syntax to read code. > It was pretty impressive, a compiler actually > trying to be helpful. The right thing for a compiler to do is to insert the semi-colon for the *sole* purpose of finding more errors. However, putting error recovery in a compiler tends to complexify it a lot. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com
From: Subject: Re: colostomy Date: Tuesday, March 28, 2000 11:27 PM Moshe Zadka wrote: > On Wed, 29 Mar 2000 dirckb@my-deja.com wrote: > > > A long time ago I used a C compiler on the DEC > > VAX that would issue this warning message: > > "missing semi-colon, assumed." > > and Keep Compiling! > > That's exactly! what Guido hates, and I agree. > How do you think we got in HTML hell? > Precisely because browsers were trying to be helpful. TMTWODI > just means you have to learn more then one syntax to read code. > I don't think I would attribute HTML hell to browsers trying to be helpful. Why use a program if it isn't helpful? Just stick to pencil and paper... There is always more than one way to do something, just because no two people think exactly the same way. A small coherent tool set, instead of a kitchen sink approach, makes it more likely that the implementation will be coherent to other people as well. Python has distinct advantages here: a clear vision, and a single reference implementation. (c++ actually started out that way - oh well). Any program suffers if it tries to be all things to all people. HTML suffers from being a 'standard'. Implementors interpret standards differently, and if the standard doesn't cover desired functionality, they don't always make good decisions about extending it. In the case of browsers, the developers went every which way trying to add more functionality. The browser wars weren't exactly a model of cooperation, either. A reference implementation is ideal because you can't argue about what a program does - it just does what it does. If you match the reference, you are 'correct'. Because Python is open, anybody can try out any hack they like. Presumably, on occasion, if a hack is useful and popular, it might be blessed, and end up in the reference implementation. Otherwise it will end up unsupported. I think there is a definite difference between flexibility and incoherence. Most software issues are subjective, and subject to personal tastes. It's important to weigh issues on their relative merits, and not try to develop based on absolutes. [ there is no substitute for understanding if you don't know what you are doing, rules won't help if you do know what you are doing, rules are irrelevant (if you are learning, rules can help lead the way) ] But I digress. It was a pet peeve of mine, and a fun hack. I can see how it added a few ugly bits to the compiler code, though it slid in reasonably well because of Python's architecture. I brought it up because there was some discussion about Python 3k being source level incompatible, which indicates some ideas are in flux. Doesn't sound like anyone shares my enthusiasm for the minimalist syntax, which isn't a big deal. Over time I will adapt ok. In the mean time, if i ever get frustrated when I keep messing up, I can switch to a slightly more tolerant python and focus on the programming, not on the programming language. > > It was pretty impressive, a compiler actually > > trying to be helpful. > > The right thing for a compiler to do is to insert the semi-colon > for the *sole* purpose of finding more errors. However, putting > error recovery in a compiler tends to complexify it a lot. Yeah, that's the hard part. If the compiler isn't smart enough it gets lost in a useless cascade of phantom errors. Lightspeed (er, Think, er, Symantec, er...) C on the Mac used to just stop dead on the first error and leave the cursor there for you to fix it. That's one way to do it. Of course, you never had any idea how close you were to actually running... My thinking was, if the compiler is smart enough to put it in, why does it need to be there in the first place? what purpose does it serve? ... Geeze, I best shut up now. Sorry to be so long winded. Thanks for all the responses! d (news.pacbell.net STILL otl) dirck@danbala.com http://www.danbala.com http://starship.python.net/crew/dirck Sent via Deja.com http://www.deja.com/ Before you buy.
From: Niklas Frykholm Subject: Re: colostomy Date: Wednesday, March 29, 2000 3:27 AM In article <8bsb8n$2ki$1@nnrp1.deja.com>, dirck@pacbell.net wrote: >I brought it up because there was >some discussion about Python 3k being source level incompatible, which >indicates some ideas are in flux. Doesn't sound like anyone shares my >enthusiasm for the minimalist syntax, which isn't a big deal. Over >time I will adapt ok. In the mean time, if i ever get frustrated when >I keep messing up, I can switch to a slightly more tolerant python and >focus on the programming, not on the programming language. I sometimes forget the colon too, but I believe that this should be addressed in the editor rather than in the compiler. (You don't want your printer driver to do spell checking.) May I suggest adding the following to your python-mode.el file: (Disclaimer: I am not an elisp programmer.) (defun colostomy-fix () "Adds a colon to a python line if necessary." (let ( (need-colon-regexp "[\\t]*\\(if\\|def\\|else\\|elif\\|\ while\\|for\\|except\\|finally\\|try\\|class\\)") (has-colon-regexp ".*:[ \\t]*$") (need-colon nil) (has-colon nil)) (save-excursion (beginning-of-line) (setq need-colon (looking-at need-colon-regexp)) (setq has-colon (looking-at has-colon-regexp)) ) (if (and need-colon (not has-colon)) (insert ":") ()) )) And modifying the definition of py-newline-and-indent so that it reads: (defun py-newline-and-indent () (interactive) (colostomy-fix) (let ((ci (current-indentation))) ... This is a bit of a hack... for example it doesn't work when lines have been broken with \. But it works in most cases. // Niklas
From: Remco Gerlich Subject: Re: colostomy Date: Wednesday, March 29, 2000 6:34 AM dirck@pacbell.net wrote in comp.lang.python: [ On needing the : at the end of control statements ] > My thinking was, if the compiler is smart enough to put it in, > why does it need to be there in the first place? > what purpose does it serve? Let's, we have several control statements... try, except, finally, for, while, if, class, def, lambda... something like that. Why not call them t e fi fo w i c d and l? :-) The compiler is smart enough for that... The : is there for the same reason Python uses indentation as block markers in the first place; there were studies done for the ABC language, with subjects grading different block structures for readability (or something like that). It was found that block x: spam spam spam Is *slightly* more readable than block x spam spam spam That's all. I agree with the study. Besides, I like it in editors, since the editor can automatically indent the line after : , so block structure is more automatic. -- Remco Gerlich, scarblac@pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours!
From: Dirck Blaskey Subject: Re: colostomy Date: Wednesday, March 29, 2000 11:00 PM Remco Gerlich wrote in message news:slrn8e48f6.5oc.scarblac-spamtrap@flits104-37.flits.rug.nl... > dirck@pacbell.net wrote in comp.lang.python: > [ On needing the : at the end of control statements ] > > My thinking was, if the compiler is smart enough to put it in, > > why does it need to be there in the first place? > > what purpose does it serve? > > Let's, we have several control statements... try, except, finally, for, > while, if, class, def, lambda... something like that. Why not call them t e > fi fo w i c d and l? :-) The compiler is smart enough for that... Maybe I should switch to APL ? :-)
From: Dennis Lee Bieber Subject: Re: colostomy Date: Wednesday, March 29, 2000 11:33 PM On Wed, 29 Mar 2000 23:00:59 -0800, "Dirck Blaskey" declaimed the following in comp.lang.python: > > Maybe I should switch to APL ? :-) > 4 5 $r 20 ? 52 (using one of the alternate notations for the greek alphabet) -- > ============================================================== < > wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed@dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ <
From: Subject: Re: colostomy Date: Friday, March 31, 2000 1:55 AM >Please, PLEASE make colon's optional when not needed. >After more than a year, I still frequently type this: > if condition # or def or while or for etc. > do something > >instead of > if condition: > do something > It might help to mentally connect the ":" with the word "begin" or "do" - at least that's what works for me most of the time. Greetings, Albert
From: John W. Baxter Subject: Re: colostomy Date: Friday, March 31, 2000 6:31 PM In article <38e4758d.5444248@nntpserver.edvg.co.at>, Albert_Brandl@edvg.co.at wrote: > >Please, PLEASE make colon's optional when not needed. > >After more than a year, I still frequently type this: > > if condition # or def or while or for etc. > > do something > > > >instead of > > if condition: > > do something > > > > It might help to mentally connect the ":" with the > word "begin" or "do" - at least that's what works > for me most of the time. > > Greetings, > I generally let the emacs python-mode tell me when I've forgotten a :, which it does by failing to indent the next line "correctly". --John -- John W. Baxter Port Ludlow, WA USA jwbnews@scandaroon.com
From: Dirck Blaskey Subject: Optional Colons (was: colostomy) Date: Tuesday, March 28, 2000 2:12 PM Well, I didn't seem to be getting much sympathy, so I went ahead and implemented the hack anyway. It was educational. If you're curious, it's on my starship pages: http://starship.python.net/crew/dirck d =========================== Dirck Blaskey Danbala Software dirck@danbala.com http://www.danbala.com