?
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?=
Do you use proportional fonts when you're programming?
Yes, of course.
Do you use proportional fonts when you're programming?
Antoon said:Yes, and I would also be interested in an other proposal
that went something like:
while condition1:
code
and while condition2:
code
and while condition3:
code
maybe we should combine them into something like
do:
code
and while condition1:
code
and while condition3:
code
Antoon said:Well that would of course be the best solution. But in absence
of a more general loop construction I'm willing to settle for
a construction that looks like it, even if it has to be
simulated.
Maybe you are just not familiar with more general loop constructs.
What the algorithm is trying to do is find the least significant bit
that is on. It does so by applying succeeding masks to the number
each mask is all ones and double in length as the previous mask.
when applying a mask results in a number different from 0, the
number is shifted the length of the previous mask and the length
is added to the offset. The process is then repeated with the
mask initialized at 1. The algorthm stops when applying a mask
of 1 already differs from 0.
Antoon said:Yes, and I would also be interested in an other proposal
that went something like:
while condition1:
code
and while condition2:
code
and while condition3:
code
maybe we should combine them into something like
do:
code
and while condition1:
code
and while condition3:
code
In Vim:
set sw=4 sta et ai bs=2
Put that in your .vimrc, and you're done. The key labelled Tab is now
just a convenient way of specifying "indent the standard four spaces",
and backspace on leading spaces removes the last four. Done.
Paramjit said:Andrew Koenig proposed this in the following email:
http://groups.google.com/[email protected]
If link doesn't work - it was a post dated 2003-05-05 with the subject
"Re: PEP 315: Enhanced While Loop". There was a fairly long thread about
it back then.
A quote from the message:
while <condition1>:
<code1>
and while <condition2>:
<code2>
and while <condition3>:
<code3>
[snip] would be equivalent to
while <condition1>:
<code1>
if not (<condition2>): break
<code2>
if not (<condition3>): break
<code3>
I don't like that style. I think it's better to have the if and else atif (condition) {
doThis();
doThat();
} else {
doWhatever();
andSoOn();
}
I also agree. I love the fact that you can't produce bad indented codewhich only takes 7 lines and is not much less readable. But I agree with
you!
I don't like that style. I think it's better to have the if and else at
the same level. ie:
if (condition) {
doThis();
doThat();
}
else {
doWhatever();
andSoOn();
}
Christopher T King said:I dunno... that looks like some kind of voodoo chant to me...
Josef said:I also agree. I love the fact that you can't produce bad indented code
in python
Paramjit said:Andrew Koenig proposed this in the following email:
http://groups.google.com/[email protected]
If link doesn't work - it was a post dated 2003-05-05 with the subject
"Re: PEP 315: Enhanced While Loop". There was a fairly long thread about
it back then.
Paramjit Oberoi said:Andrew Koenig proposed this in the following email:
http://groups.google.com/[email protected]
If link doesn't work - it was a post dated 2003-05-05 with the subject
"Re: PEP 315: Enhanced While Loop". There was a fairly long thread about
it back then.
Peter said:Well, if you try hard enough, you can still get pretty brutal:
a = 5
if a == 6: print '6'
else:
if a == 7:
print '7'
\
elif a \
== 8:
print '8'
else:
print 'none of the above'
Peter said:Andrew's interpretation doesn't fit mine. I look at
the above and wonder why the code2 block doesn't
continue to execute until condition2 fails, and then
the code3 block loops repeatedly until condition3
fails...
Oh yes, I forgot that the backslash "\" could break the indentation. Buta = 5
if a == 6: print '6'
else:
if a == 7:
print '7'
\
elif a \
== 8:
print '8'
else:
print 'none of the above'
;-)
-Peter
Op 2004-07-09 said:-1.
I do occasionally write loops where I do something, test and maybe
break, and then go on to do something else. However, the current while
construct does that just fine, and clearly expresses the start and end
of the code block:
linenum=1
while True:
line = raw_input()
if not line: break # or put on its own line, depending on taste
print "%05d:%s" % (linenum, line,)
linenum += 1
This confuses me as to where the loop starts and ends:
linenum=1
while True:
line = raw_input()
and while line:
print "%05d:%s" % (linenum, line,)
linenum += 1
I rarely use post-loop condition testing even in Java where it exists
and you can use assignment as an expression, let alone in Python. When
I do, an explicit if...break at the end works fine.
Chris Share said:FYI, it's pretty simple...
I use vim for writing python in, with the following options:
:set et
:set tabstop=4
And how do I get it to send the function definition surrounding the
cursor to the Python interpreter with which it is currently
interacting ?
Antoon Pardon said:This confusion may be nothing more than your unfamiliary which
such a construct.
That is not an argument.
Before instructions like while, repeat etc
existed, we could use the equivallent of an if combined with a goto
and that worked fine too.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.