473,795 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

print() in Python 3000 return value?

I noticed in PEP 3000 that print will become a function. The PEP
references a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?

Apr 2 '06 #1
10 1551
James Thiele wrote:
I noticed in PEP 3000 that print will become a function. The PEP
references a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?


My intuition is that it should be a procedure (i.e. returning None).

What do you want it to return?

Regards,
Martin
Apr 2 '06 #2
Martin chimedin:
James Thiele wrote:
I noticed in PEP 3000 that print will become a function. The PEP
references a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?


My intuition is that it should be a procedure (i.e. returning None).
What do you want it to return?

Regards,
Martin


The string that was printed. It could be useful inside expessions:

message = "I don't need to see all of this:%s" % print(s)

Apr 2 '06 #3
Em Dom, 2006-04-02 Ã*s 10:41 -0700, James Thiele escreveu:
Martin chimedin:
James Thiele wrote:
I noticed in PEP 3000 that print will become a function. The PEP
references a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?


My intuition is that it should be a procedure (i.e. returning None).
What do you want it to return?

Regards,
Martin


The string that was printed. It could be useful inside expessions:

message = "I don't need to see all of this:%s" % print(s)


Or maybe:

for i in sequence:
mylist.append(p rint(i))

--
Felipe.

Apr 2 '06 #4
Expressions like
2 + 2


return None, too. I am not certain, but as far as I know this has some
major design reasons. Thus I am certain, that print() will return None
also.

Apr 2 '06 #5
Felipe Almeida Lessa wrote:
Em Dom, 2006-04-02 Ã*s 10:41 -0700, James Thiele escreveu:

Martin chimedin:

James Thiele wrote:
I noticed in PEP 3000 that print will become a function. The PEP
reference s a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?
My intuition is that it should be a procedure (i.e. returning None).
What do you want it to return?

Regards,
Martin

The string that was printed. It could be useful inside expessions:

message = "I don't need to see all of this:%s" % print(s)


Or maybe:

for i in sequence:
mylist.append(p rint(i))

No no, please NO! You *know* that someday you'll want the return value
without actually printing the text.

So let's don't overload a single function with two operations. Let
"print" print, and propose a separate function (named "format" --yuck--
or some such) that returns the same text as a string.

Gary Herron

Apr 2 '06 #6
bayerj wrote:
Expressions like
2 + 2


return None, too.


Sorry? 2+2 here returns 4, and certainly should with your Python.

Georg
Apr 2 '06 #7
Gary Herron wrote:
for i in sequence:
mylist.append(p rint(i))

No no, please NO! You *know* that someday you'll want the return value
without actually printing the text.

So let's don't overload a single function with two operations. Let
"print" print, and propose a separate function (named "format" --yuck--
or some such) that returns the same text as a string.


Yes! That's really a good idea. But "format" is a bad name. Let's call it
"as_string" !

Hm, bad too. What about "text"?

No, now I know. Let it be called "str".

Georg
Apr 2 '06 #8
James Thiele wrote:
I noticed in PEP 3000 that print will become a function. The PEP
references a thread where Guido explains this decision. The thread does
not specify what the function will return. Has this been decided?


reading the discussion, the arguments are about "print" as of now being
a syntactic construc, an operator without apparent reason. all that is
proposed is to tuck it as a function/procedure, i.e. use parenthesis
and be able to redefine with a simple def print(...)

if you think about it, the pythonic way is for print to return None. we
use it for the side effect (stdout output)

Apr 2 '06 #9
> Sorry? 2+2 here returns 4, and certainly should with your Python.

Err. Never mind. I was thinking about assignments, like
x += 2


which returns None.

Apr 2 '06 #10

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

Similar topics

14
2920
by: Marcin Ciura | last post by:
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version: $Revision: 0.0 $
22
1956
by: James H. | last post by:
Greetings! I'm new to Python and am struggling a little with "and" and "or" logic in Python. Since Python always ends up returning a value and this is a little different from C, the language I understand best (i.e. C returns non-zero as true, and zero as false), is there anything I should be aware of given Python's different approach? Namely any pitfalls or neat tricks that make the Python approach cool or save my butt. Thank you!
69
3226
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of this pep would be to make it impossible to use the name 'print' in a backward compatible manner. Indeed, if a program is to compile in both Python 2.x and Python 3.x, the print function (or the print statement with parentheses) can not use the...
0
1985
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches ______________________
0
9672
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
9519
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
10436
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...
1
10163
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,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
3
2920
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.