python - Is it a good habit to print the bool value from a function? -


def f():     return true  print(f()) 

or

def f():     return true  if f():     print('true') else:     print('false') 

should round in if statement or print out value, in python 3.3.2?

print automatically converts input string representation. so, 2 methods exact same thing. considering that, why not use first? lot cleaner.

also, second method can simplified:

print('true' if f() else 'false') 

having code simple isn't necessary.


Comments

Popular posts from this blog

c# - Attribute value in root node of xml Linq to XML -

ios swift - uiimage array to video disorted and flipped -

scala, transform a callback pattern to a functional style internal iterator -