Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [perl-python] 20050112 while statement

Reply
Thread Tools

[perl-python] 20050112 while statement

 
 
Xah Lee
Guest
Posts: n/a
 
      01-13-2005
# 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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://xahlee.org/PageTwo_dir/more.html

 
Reply With Quote
 
 
 
 
Michael Hoffman
Guest
Posts: n/a
 
      01-13-2005
Xah Lee wrote:
> # here's a while statement in python.
>
> [...]
>
> # here's the same code in perl
>
> [...]


So?
--
Michael Hoffman
 
Reply With Quote
 
 
 
 
brianr@liffe.com
Guest
Posts: n/a
 
      01-13-2005
"Xah Lee" <(E-Mail Removed)> 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 <(E-Mail Removed)>
 
Reply With Quote
 
Peter Maas
Guest
Posts: n/a
 
      01-13-2005
(E-Mail Removed) schrieb:
> "Xah Lee" <(E-Mail Removed)> 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')
-------------------------------------------------------------------
 
Reply With Quote
 
Steven Bethard
Guest
Posts: n/a
 
      01-13-2005
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
 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      01-13-2005
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
 
Reply With Quote
 
Charlton Wilbur
Guest
Posts: n/a
 
      01-13-2005
>>>>> "b" == brianr <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
[perl-python] 20050112 while statement Xah Lee Python 7 01-13-2005 11:59 PM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments