Print vs. Return


#1

Someone else said that returning something gives that information to the console and that printing something depicts that information on the interpreter for the user to see. Does that mean that users never view returned info? Thanks! :smile:


#2

They won't see the return object if it is not printed. Printing can take place in the function, or we can print the function call expression.

def print_inside(text):
    print "<Text: \"%s\">" % text

def no_print_inside(text):
    return "<Text: \"%s\">" % text

Usage:

 > print_inside("Go Oilers!")
 <Text: "Go Oilers!">
 > print(no_print_inside("Go Oil Kings!"))
 <Text: "Go Oil Kings!">