from __future__ import print

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samslists@gmail.com

    from __future__ import print

    Am I the only one that thinks this would be useful? :)

    I'd really like to be able to use python 3.0's print statement in
    2.x. Is this at least being considered as an option for 2.6? It
    seems like it would be helpful with transitioning.
  • Andrii V. Mishkovskyi

    #2
    Re: from __future__ import print

    2008/4/10, samslists@gmail .com <samslists@gmai l.com>:
    Am I the only one that thinks this would be useful? :)
    >
    I'd really like to be able to use python 3.0's print statement in
    2.x. Is this at least being considered as an option for 2.6? It
    seems like it would be helpful with transitioning.
    It's not only considered but have been already implemented. Enjoy. :)

    Python 2.6a2+ (trunk:62269, Apr 10 2008, 20:18:42)
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.
    >>from __future__ import print_function
    >>print "asd"
    File "<stdin>", line 1
    print "foo"
    ^
    SyntaxError: invalid syntax
    >>print("foo" )
    foo

    --
    Wbr, Andrii Mishkovskyi.

    He's got a heart of a little child, and he keeps it in a jar on his desk.

    Comment

    • Bruno Desthuilliers

      #3
      Re: from __future__ import print

      samslists@gmail .com a écrit :
      Am I the only one that thinks this would be useful? :)
      >
      I'd really like to be able to use python 3.0's print statement in
      2.x.
      <nitpick mode="pedantic" >
      FWIW, the whole point is that in 3.0, print stop being a statement to
      become a function...
      </nitpick>

      Comment

      • ockman@gmail.com

        #4
        Re: from __future__ import print

        On Apr 10, 3:06 pm, "Andrii V. Mishkovskyi" <misho...@gmail .com>
        wrote:
        2008/4/10, samsli...@gmail .com <samsli...@gmai l.com>:
        >
        Am I the only one that thinks this would be useful? :)
        >
        I'd really like to be able to use python 3.0'sprintstate ment in
        2.x. Is this at least being considered as an option for 2.6? It
        seems like it would be helpful with transitioning.
        >
        It's not only considered but have been already implemented. Enjoy. :)
        Awesome! I'm still stuck on 2.5 but I'm glad to know it's in 2.6. :)

        Comment

        • Lie

          #5
          Re: from __future__ import print

          On Apr 11, 7:26 pm, Bruno Desthuilliers <bruno.
          42.desthuilli.. .@websiteburo.i nvalidwrote:
          samsli...@gmail .com a écrit :
          >
          Am I the only one that thinks this would be useful? :)
          >
          I'd really like to be able to use python 3.0's print statement in
          2.x.
          >
          <nitpick mode="pedantic" >
          FWIW, the whole point is that in 3.0, print stop being a statement to
          become a function...
          </nitpick>
          But the reason it becomes a function is because being a statement it
          is inflexible and there is no way to pass arguments to the print
          function, at the cost of extra typing of parentheses. I wish py3k
          would make it an option whether to treat print as statement or
          function though. Since not all programs require the power of print as
          a function and having to type the extra parentheses is a bit tiring if
          you're printing lots of things. Probably it may be coupled with a
          translator (for source code from statement to function, since the
          reverse would not be practical) if you changed your mind.

          Comment

          • Roy Smith

            #6
            Re: from __future__ import print

            In article
            <ce23a66d-ac4b-4f23-a9ea-8d1592b0845a@w8 g2000prd.google groups.com>,
            Lie <Lie.1296@gmail .comwrote:
            I wish py3k
            would make it an option whether to treat print as statement or
            function though.
            Arrrgghhhhh! No, don't even go there. If you want optional parens, use
            Perl :-)

            Comment

            • Lie

              #7
              Re: from __future__ import print

              On Apr 13, 7:23 pm, Roy Smith <r...@panix.com wrote:
              In article
              <ce23a66d-ac4b-4f23-a9ea-8d1592b08...@w8 g2000prd.google groups.com>,
              >
              Lie <Lie.1...@gmail .comwrote:
              I wish py3k
              would make it an option whether to treat print as statement or
              function though.
              >
              Arrrgghhhhh! No, don't even go there. If you want optional parens, use
              Perl :-)
              Not optional parens, but a simple print statement coupled with a
              powerful print function. This print statement would only have basic
              printing functionality such as :

              print "Hello"
              print var
              print var, "Hello too"

              specifically, these would be removed:
              print var,
              print >unstdout, var

              This is because it is sometimes annoying to type this:
              print("Hello")
              print("World")
              print("This")
              print("is")
              print("Captain" )
              print("Kirk")

              because of the double enclosement (parens () and quotes ""),
              especially when you're just slipping a simple debugging statement.

              This also eases transition between older codes, because while you uses
              regular print statements everyday, you don't do print redirection and
              comma-ended printing everyday, and it would be easier to just convert
              those advanced printing functionality rather than converting all
              printing statements.

              Comment

              • Diez B. Roggisch

                #8
                Re: from __future__ import print

                Lie schrieb:
                On Apr 13, 7:23 pm, Roy Smith <r...@panix.com wrote:
                >In article
                ><ce23a66d-ac4b-4f23-a9ea-8d1592b08...@w8 g2000prd.google groups.com>,
                >>
                > Lie <Lie.1...@gmail .comwrote:
                >> I wish py3k
                >>would make it an option whether to treat print as statement or
                >>function though.
                >Arrrgghhhhh! No, don't even go there. If you want optional parens, use
                >Perl :-)
                >
                Not optional parens, but a simple print statement coupled with a
                powerful print function. This print statement would only have basic
                printing functionality such as :
                >
                print "Hello"
                print var
                print var, "Hello too"
                >
                specifically, these would be removed:
                print var,
                print >unstdout, var
                >
                This is because it is sometimes annoying to type this:
                print("Hello")
                print("World")
                print("This")
                print("is")
                print("Captain" )
                print("Kirk")
                You are aware that it is only one character more to type?

                It is debatable if print should have gone or not - but once you decide
                to have a print-statement I fail to see why you want to rid it of
                functionality. The costs for a keyword and special parsing rules are
                paid anyway then.

                Diez

                Diez

                Comment

                Working...