[perl-python] 20050112 while statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Xah Lee

    #1

    [perl-python] 20050112 while statement

    # 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
    xah@xahlee.org


  • Michael Hoffman

    #2
    Re: [perl-python] 20050112 while statement

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

    So?
    --
    Michael Hoffman

    Comment

    • brianr@liffe.com

      #3
      Re: [perl-python] 20050112 while statement

      "Xah Lee" <xah@xahlee.org > writes:
      [color=blue]
      > # 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);
      > }[/color]

      That python code produces a syntax error:

      File "w.py", line 3
      print b
      ^
      IndentationErro r: 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 <199702221943.L AA20388@wall.or g>

      Comment

      • Peter Maas

        #4
        Re: [perl-python] 20050112 while statement

        brianr@liffe.co m schrieb:[color=blue]
        > "Xah Lee" <xah@xahlee.org > writes:[/color]
        [...][color=blue]
        > (As a matter of interest, is this sequence of posts intended to
        > demonstrate ignorance of both languages, or just one?)[/color]

        :)

        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 'cGV0ZXIubWFhc0 BtcGx1c3IuZGU=\ n'.decode('base 64')
        -------------------------------------------------------------------

        Comment

        • Steven Bethard

          #5
          Re: [perl-python] 20050112 while statement

          Xah Lee wrote:[color=blue]
          > # 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);
          > }[/color]

          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
          IndentationErro rs.

          Personally, I think you should not do this over comp.lang.pytho n (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.pytho n community, and
          might me more appropriate in a different venue.

          Steve

          Comment

          • Peter Hansen

            #6
            Re: [perl-python] 20050112 while statement

            Steven Bethard wrote:[color=blue]
            > Xah Lee wrote:[/color]
            [some Python code][color=blue]
            > 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
            > IndentationErro rs.[/color]

            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

            Comment

            • Abigail

              #7
              Re: [perl-python] 20050112 while statement

              Xah Lee (xah@xahlee.org ) wrote on MMMMCLIII September MCMXCIII in
              <URL:news:11056 11506.106440.13 5670@f14g2000cw b.googlegroups. com>:
              ... # here's a while statement in python.
              ...
              ... a,b = 0,1
              ... while b < 20:
              ... print b

              IndentationErro r: 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'""'=>s ub{$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

              Comment

              • Charlton Wilbur

                #8
                Re: [perl-python] 20050112 while statement

                >>>>> "b" == brianr <brianr@liffe.c om> 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

                Comment

                Working...