[perl-python] 20050112 while statement

Discussion in 'Python' started by Xah Lee, Jan 13, 2005.

  1. Xah Lee

    Xah Lee Guest

    # 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://xahlee.org/PageTwo_dir/more.html
    Xah Lee, Jan 13, 2005
    #1
    1. Advertising

  2. Xah Lee wrote:
    > # here's a while statement in python.
    >
    > [...]
    >
    > # here's the same code in perl
    >
    > [...]


    So?
    --
    Michael Hoffman
    Michael Hoffman, Jan 13, 2005
    #2
    1. Advertising

  3. Xah Lee

    Guest

    "Xah Lee" <> 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 <>
    , Jan 13, 2005
    #3
  4. Xah Lee

    Peter Maas Guest

    schrieb:
    > "Xah Lee" <> 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')
    -------------------------------------------------------------------
    Peter Maas, Jan 13, 2005
    #4
  5. 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
    Steven Bethard, Jan 13, 2005
    #5
  6. Xah Lee

    Peter Hansen Guest

    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
    Peter Hansen, Jan 13, 2005
    #6
  7. Xah Lee

    Abigail Guest

    Xah Lee () wrote on MMMMCLIII September MCMXCIII in
    <URL:news:>:
    ... # 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";#Abigail
    Abigail, Jan 13, 2005
    #7
  8. >>>>> "b" == brianr <> 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
    Charlton Wilbur, Jan 13, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jjliu

    While statement in perl

    jjliu, Oct 11, 2003, in forum: Perl
    Replies:
    1
    Views:
    661
  2. Replies:
    3
    Views:
    800
  3. Xah Lee
    Replies:
    6
    Views:
    93
    Charlton Wilbur
    Jan 13, 2005
  4. hito koto
    Replies:
    17
    Views:
    62
  5. hito koto

    Python deepcopy to while statement

    hito koto, Jun 13, 2014, in forum: Python
    Replies:
    2
    Views:
    80
    hito koto
    Jun 13, 2014
Loading...

Share This Page