from __future__ import print

Discussion in 'Python' started by samslists@gmail.com, Apr 10, 2008.

  1. Guest

    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.
    , Apr 10, 2008
    #1
    1. Advertising

  2. 2008/4/10, <>:
    > 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

    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >



    --
    Wbr, Andrii Mishkovskyi.

    He's got a heart of a little child, and he keeps it in a jar on his desk.
    Andrii V. Mishkovskyi, Apr 10, 2008
    #2
    1. Advertising

  3. 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>
    Bruno Desthuilliers, Apr 11, 2008
    #3
  4. Guest

    On Apr 10, 3:06 pm, "Andrii V. Mishkovskyi" <>
    wrote:
    > 2008/4/10, <>:
    >
    > > Am I the only one that thinks this would be useful? :)

    >
    > > I'd really like to be able to use python 3.0'sprintstatement 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. :)
    , Apr 12, 2008
    #4
  5. Lie Guest

    On Apr 11, 7:26 pm, Bruno Desthuilliers <bruno.
    > wrote:
    > 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.
    Lie, Apr 13, 2008
    #5
  6. Roy Smith Guest

    In article
    <>,
    Lie <> wrote:

    > 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 :)
    Roy Smith, Apr 13, 2008
    #6
  7. Lie Guest

    On Apr 13, 7:23 pm, Roy Smith <> wrote:
    > In article
    > <>,
    >
    > Lie <> wrote:
    > > 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.
    Lie, Apr 20, 2008
    #7
  8. Lie schrieb:
    > On Apr 13, 7:23 pm, Roy Smith <> wrote:
    >> In article
    >> <>,
    >>
    >> Lie <> wrote:
    >>> 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
    Diez B. Roggisch, Apr 20, 2008
    #8
  9. Roy Smith Guest

    "Diez B. Roggisch" <> wrote:

    > You are aware that it is only one character more to type?


    I'm not arguing for print vs. print(), but I do want to comment on the
    "character count" argument.

    I'm a pretty good typist, the result of having been forced in junior high
    school (in the mid 70's) to learn typing the "right way" -- on a typewriter
    with blank keycaps. It forced you to really learn to touch-type. I don't
    know if this was some touchy-feely idea that if they girls had to learn to
    type (after all, they were all going to be secretaries) then it's only fair
    to make the boys learn it too. Or, if they were just amazingly prescient
    about computers taking over the world and typing becoming an important
    high-tech skill. Either way, I learned to touch type.

    That being said, hitting the space bar is pretty much a freebie. You can
    do it with either thumb(*), and you don't have to move your fingers from
    the home row. To get the ( and ), you have to reach way up to the top row
    with one hand and down hit the shift key with the opposite pinkie. A much
    costlier operation in terms of maintaining a good typing speed.

    On the other hand, it's a well known (or at least well believed :)) fact
    that code is read many more times than it's written. Making something
    easier to read is much more important than making it easy to type.

    (*) Oddly enough, as I type this and pay attention to what my fingers are
    doing, I find that I almost exclusively use the *left* thumb, which I never
    noticed before.
    Roy Smith, Apr 20, 2008
    #9
    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. Logan
    Replies:
    3
    Views:
    748
    Michael Hudson
    Nov 25, 2003
  2. Jacek Generowicz

    from __future__ import decorators

    Jacek Generowicz, Jan 13, 2005, in forum: Python
    Replies:
    8
    Views:
    360
    Jacek Generowicz
    Jan 17, 2005
  3. Replies:
    2
    Views:
    297
  4. Ron Adam
    Replies:
    7
    Views:
    489
    Ron Adam
    Feb 9, 2007
  5. Malcolm Greene
    Replies:
    1
    Views:
    355
    Dan Bishop
    Apr 12, 2008
Loading...

Share This Page