By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

[perl-python] 20050112 while statement

P: n/a
# here's a while statement in python.

a,b = 0,1
while b < 20:
print b
a,b = b,a+b

---------------
# here's the same code in perl

($a,$b)=(0,1);
while ($b<20) {
print $b, "\n";
($a,$b)= ($b, $a+$b);
}
Xah
xa*@xahlee.org
http://xahlee.org/PageTwo_dir/more.html

Jul 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Xah Lee wrote:
# here's a while statement in python.

[...]

# here's the same code in perl

[...]


So?
--
Michael Hoffman
Jul 18 '05 #2

P: n/a
"Xah Lee" <xa*@xahlee.org> writes:
# here's a while statement in python.

a,b = 0,1
while b < 20:
print b
a,b = b,a+b

---------------
# here's the same code in perl

($a,$b)=(0,1);
while ($b<20) {
print $b, "\n";
($a,$b)= ($b, $a+$b);
}


That python code produces a syntax error:

File "w.py", line 3
print b
^
IndentationError: expected an indented block

So, not the same then!

(As a matter of interest, is this sequence of posts intended to
demonstrate ignorance of both languages, or just one?)

--
Brian Raven
If you write something wrong enough, I'll be glad to make up a new
witticism just for you.
-- Larry Wall in <19*******************@wall.org>
Jul 18 '05 #3

P: n/a
br****@liffe.com schrieb:
"Xah Lee" <xa*@xahlee.org> writes: [...] (As a matter of interest, is this sequence of posts intended to
demonstrate ignorance of both languages, or just one?)


:)

This sequence of posts is intended to stir up a debate just for
the sake of a debate. It's a time sink. It's up to you wether you
want to post to this thread or do something useful. :)

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------
Jul 18 '05 #4

P: n/a
Xah Lee wrote:
# here's a while statement in python.

a,b = 0,1
while b < 20:
print b
a,b = b,a+b

---------------
# here's the same code in perl

($a,$b)=(0,1);
while ($b<20) {
print $b, "\n";
($a,$b)= ($b, $a+$b);
}


Because you're posting this to newsgroups, it would be advisable to use
only spaces for indentation -- tabs are removed by a lot of newsreaders,
which means your Python readers are going to complain about
IndentationErrors.

Personally, I think you should not do this over comp.lang.python (and
perhaps others feel the same way about comp.lang.perl.misc?) Can't you
start a Yahoo group or something for this? What you're doing is
probably not of interest to most of the comp.lang.python community, and
might me more appropriate in a different venue.

Steve
Jul 18 '05 #5

P: n/a
Steven Bethard wrote:
Xah Lee wrote: [some Python code] Because you're posting this to newsgroups, it would be advisable to use
only spaces for indentation -- tabs are removed by a lot of newsreaders,
which means your Python readers are going to complain about
IndentationErrors.


Unfortunately, there are now two ways to post screwed up Python
code, and using tabs is only one of them.

The other is to post from Google Groups, and that's what Xah Lee
is doing.

(The rest of your advice, about going away, is pretty good though. ;-)

-Peter
Jul 18 '05 #6

P: n/a
Xah Lee (xa*@xahlee.org) wrote on MMMMCLIII September MCMXCIII in
<URL:news:11**********************@f14g2000cwb.goo glegroups.com>:
... # here's a while statement in python.
...
... a,b = 0,1
... while b < 20:
... print b

IndentationError: expected an indented block

... a,b = b,a+b
You have already proven you don't know Perl, but now it turns
out, you don't know Python either.

Go away.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abig ail
Jul 18 '05 #7

P: n/a
>>>>> "b" == brianr <br****@liffe.com> writes:

b> (As a matter of interest, is this sequence of posts intended to
b> demonstrate ignorance of both languages, or just one?)

Intentional fallacy -- there's no necessary correlation between what
he *intends* to do and what he actually succeeds at doing. As noted,
Xah *intends* to use his expertise in Perl to teach Python to others.
All he's succeeding in doing is demonstrating his incompetence at
both. As for myself, I suspect it's just a cunning approach to Let's
You And Him Fight.

Charlton

--
cwilbur at chromatico dot net
cwilbur at mac dot com
Jul 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.