Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58061
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Subject | Re: First day beginner to python, add to counter after nested loop |
| Newsgroups | comp.lang.python |
| References | (8 earlier) <CAPTjJmoW41xSsTx+wjHG64=OGA2FcY+YY1Ceas3wq5pJv42YFw@mail.gmail.com> <mailman.1804.1383136979.18130.python-list@python.org> <_C8cu.52337$gs7.11961@fx16.am4> <mailman.1809.1383144994.18130.python-list@python.org> <n9acu.52341$gs7.24809@fx16.am4> |
| Message-ID | <1gacu.52343$gs7.42832@fx16.am4> (permalink) |
| Organization | virginmedia.com |
| Date | 2013-10-30 16:14 +0000 |
On Wed, 30 Oct 2013 16:07:47 +0000, Alister wrote:
> On Wed, 30 Oct 2013 15:56:32 +0100, Antoon Pardon wrote:
>
>> Op 30-10-13 15:22, Alister schreef:
>>> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
>>>
>>>> Op 30-10-13 13:17, Chris Angelico schreef:
>>>>> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>>>>> <antoon.pardon@rece.vub.ac.be> wrote:
>>>>> I broadly agree with your post (I'm of the school of thought that
>>>>> braces are better than indentation for delimiting blocks), but I
>>>>> don't think this argument holds water. All you need to do is be
>>>>> consistent about tabs OR spaces (and I'd recommend tabs, since
>>>>> they're simpler and safer), and you'll never have this trouble.
>>>>
>>>> Easier said than done. First of all I can be as consistent as
>>>> possible, I can't just take code from someone else and insert it
>>>> because that other person may be consistenly doing it different from
>>>> me.
>>>
>>> I disagree it is very easy.
>>
>> You can disagree, as much as you want. You don't get to define my
>> experience. Maybe all those things you enumerate are all easy, all
>> taken together they can makes it cumbersome at times.
>>
>>> 1) make sure you editor is set to inset 4 spaces rather than tab when
>>> pressing the tab key. consistency in your own code is now not an
>>> issue.
>>>
>>> 2) when importing code from someone else a simple search & replace of
>>> tab with 4 spaces will instantly correct the formatting on code using
>>> tab without breaking code that doesn't.
>>
>> But why should I have to do all that. When I write other code I just
>> don't have to bother and it is all indented as desired too.
>>
>>>> Then if you are working on different machines, the settings of your
>>>> editor may not always be the same so that you have tabs on one
>>>> machine and spaces on an other, which causes problem when you move
>>>> the code.
>>>>
>>> that is fixed by setting your environment consistantly but step 2
>>> above will fix it if you forget.
>>
>> Again why should I have to bother. Why does python force me to go
>> through all this trouble when other languages allow themselves to be
>> happily edited without all this.
>>
>>>> Also when you have an xterm, selecting a tab and pasting it into
>>>> another it will turn the tab into spaces.
>>>
>>> Read pep 11 & always use 4 spaces for indentation not tab.
>>
>> I'll decide how to layout my code.
>>
>>>> All these things usually can be ignored, they typically only show up
>>>> when you print something and things aren't aligned as you expect but
>>>> with python you are forced to correct those things immediately,
>>>> forcing you to focus on white space layout issues instead of on the
>>>> logic of the code.
>>>>
>>>>> Also, the parser should tell you if you mix tabs and spaces, so that
>>>>> won't trip anything either.
>>>>
>>>> Maybe you mean something different than I understand but a program
>>>> throwing a syntax error because there is a tab instead of a number of
>>>> spaces or vice versa, is something I would understand as tripping.
>>>
>>> no more than failing to close a brace in a C like language indentation
>>> is the syntax of python you will grow to love it, like most people I
>>> found it distracting at first even though i tended to indent other
>>> code (inconsistently)to make it readable.
>>
>> I didn't like it at first, accustomed to it a bit and then disliked it
>> again. So no I don't think I will grow to love it. Python is a tool,
>> not a religion, so I can live with it if the tool I use has some
>> featurese I dislike about it. As long as I evaluate the usefulness of
>> the tool as positive I can live with the peeves.
>>
>> What is more annoying are the people with some kind of need to reason
>> your peeves away, as if it is sacriledge daring to dislike something
>> about the language.
>
> I guess your experience & mine differ, that is personal taste I am
> certainly not trying to "reason your peeves away" just presenting an
> alternate view.
>
> Just for fun I knocked up a quick function to parse a poorly writen
> program as described by the OP (with end as a block terminator) and came
> up with the following
>
> def fixfile(i,o):
> infile=open(i,'r')
> outfile=open(o,'w')
> indent=0 for line in infile:
> text=line.strip()
> if text[-3:]=='end':
> indent=indent -1 continue
> outfile.write("%s%s\r\n"%(" "*(indent*4),text))
> if text[-1]==":":
> indent=indent+1
>
> obviously this is just proof of concept with no error checking vbut it
> did convert this:-
>
> def function():
> print "this should be indented but isnt"
> print "indented with tab"
> print "too many spaces"
> for x in range(10):
> print "this should be indented twice!"
> end print "should be indented once"
> end
> print "this should not be indented at all!"
>
>
> into this:-
>
> def function():
> print "this should be indented but isnt"
> print "indented with tab"
> print "too many spaces"
> for x in range(10):
> print "this should be indented twice!"
> print "should be indented once"
> print "this should not be indented at all!"
there is a slight typo in my example input file with a missing line break.
--
Very few things happen at the right time, and the rest do not happen
at all. The conscientious historian will correct these defects.
-- Herodotus
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 10:40 -0700
Re: First day beginner to python, add to counter after nested loop Neil Cerutti <neilc@norwich.edu> - 2013-10-29 18:09 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 11:23 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 11:35 -0700
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-29 19:24 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 13:08 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 13:11 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-29 20:37 +0000
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-30 01:44 +0000
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-29 16:30 -0400
Re: First day beginner to python, add to counter after nested loop Neil Cerutti <neilc@norwich.edu> - 2013-10-29 20:32 +0000
Re: First day beginner to python, add to counter after nested loop Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-10-30 11:53 +1300
Re: First day beginner to python, add to counter after nested loop Tim Roberts <timr@probo.com> - 2013-10-30 00:07 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 01:52 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 02:48 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 02:52 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 10:00 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:13 -0700
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 05:08 -0700
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-30 08:51 -0400
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:42 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:08 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:11 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:19 -0700
Re: First day beginner to python, add to counter after nested loop alex23 <wuwei23@gmail.com> - 2013-11-01 11:05 +1000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 07:24 -0700
Re: First day beginner to python, add to counter after nested loop Chris Angelico <rosuav@gmail.com> - 2013-10-30 21:42 +1100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 14:07 +0000
Re: First day beginner to python, add to counter after nested loop Tim Roberts <timr@probo.com> - 2013-11-02 13:19 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-03 12:33 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-11-03 04:54 -0800
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-11-03 04:55 -0800
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 13:01 +0100
Re: First day beginner to python, add to counter after nested loop Grant Edwards <invalid@invalid.invalid> - 2013-10-30 15:50 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:54 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 19:59 +0100
Re: First day beginner to python, add to counter after nested loop Chris Angelico <rosuav@gmail.com> - 2013-10-30 23:17 +1100
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 13:42 +0100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 14:22 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 07:31 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 15:09 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:35 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:51 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 15:51 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:14 -0700
Re: First day beginner to python, add to counter after nested loop Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-30 16:47 -0400
Re: First day beginner to python, add to counter after nested loop alex23 <wuwei23@gmail.com> - 2013-11-01 11:07 +1000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 08:53 -0700
Re: First day beginner to python, add to counter after nested loop Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2013-10-30 22:00 +0530
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 09:45 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 15:54 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:57 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:13 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 09:16 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 16:38 +0000
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 16:22 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:31 -0700
Re: First day beginner to python, add to counter after nested loop MRAB <python@mrabarnett.plus.com> - 2013-10-30 17:44 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 10:55 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:02 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 20:09 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:16 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 19:01 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:43 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 19:05 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:13 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 20:59 +0100
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-30 16:52 -0400
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 22:07 +0100
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 00:37 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-31 10:11 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 04:07 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-11-01 11:17 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-11-01 09:52 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-31 12:12 +0100
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 04:40 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-31 14:01 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 08:30 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:55 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 19:26 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:38 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:41 -0700
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-31 03:02 +0000
Re: First day beginner to python, add to counter after nested loop Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-30 16:50 -0400
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:19 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 15:15 +0000
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 15:56 +0100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:07 +0000
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:14 +0000
Re: First day beginner to python, add to counter after nested loop rurpy@yahoo.com - 2013-10-30 10:02 -0700
csiph-web