print() in Python 3000 return value?

Gary Herron gherron at islandtraining.com
Sun Apr 2 15:20:10 EDT 2006


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
>>>>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(print(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




More information about the Python-list mailing list