473,772 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Apr 10 '08 #1
7 10761
2008/4/10, sa*******@gmail .com <sa*******@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
>
--
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.
Apr 10 '08 #2
sa*******@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>
Apr 11 '08 #3
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. :)

Jun 27 '08 #4
Lie
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.
Jun 27 '08 #5
In article
<ce************ *************** *******@w8g2000 prd.googlegroup s.com>,
Lie <Li******@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 :-)
Jun 27 '08 #6
Lie
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.
Jun 27 '08 #7
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
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1974
by: Logan | last post by:
Is there a list with all 'from __future__ import ...' statements (which lists all the statements, in which version of Python the feature was introduced and in which version of Python it will become the default behavior)? I guess, normally such a list is not necessary because a new feature needs its 'from __future__ import ...' statement only in the present version of Python and will become default in the next version. But e.g. 'from...
8
1587
by: Jacek Generowicz | last post by:
I have some code, which makes copious use of the @decorator syntax which was introduced in Python2.4. Now I find myself in a situation where I have to run the code under Python 2.3. However, I would like to keep developing the code with the new syntax. How could I best automate the process of making the syntax digestible by Python2.3 ?
2
1859
by: mithrond | last post by:
i can't use "from __future__ import ..." statement import two statesments in the same time. for the simple code: from __future__ import with_statement, division with file('url.txt','r') as f: for line in f: print line it can't run until i change the first sentence to below from __future__ import with_statement
3
1535
by: Seymour | last post by:
I created a module with the DictAdder subclass as follows: class DictAdder(Adder): def add(self, x, y): new={} for k in x.keys(): new=x for k in y.keys(): new=y return new At the interactive prompt I then said: from Adder import *
7
20571
by: Ron Adam | last post by:
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win 32 _Ron
1
2156
by: Malcolm Greene | last post by:
Is there any consensus on what "from __future__ import" options developers should be using in their Python 2.5.2 applications? Is there a consolidated list of "from __future__ import" options to choose from? Thank you, Malcolm
0
1059
by: Tim Golden | last post by:
Malcolm Greene wrote: Well, that bit's easy: import __future__ print __future__.all_feature_names TJG
1
1996
by: Eric Hanchrow | last post by:
(This is with Python 2.5.2, on Ubuntu Hardy, if it matters.) This seems so basic that I'm surprised that I didn't find anything about it in the FAQ. (Yes, I am fairly new to Python.) Here are three tiny files: ==== mut.py ==== import system
3
1694
by: J. Cliff Dyer | last post by:
On Thu, 2008-05-08 at 12:00 -0700, Eric Hanchrow wrote: It's the same reason as this: 5 5 6 5 Python "variables" are just names that point at objects. When you
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.