0
The parenthesis of Schroedinger
Could someone explain this paradox to me: def some_func(): print("Hi!") foo = print() if foo == None: print ("empty1") else: print ("something there1") foo = () if foo == None: print ("empty2") else: print ("something there2") Output : empty1 something there2 The first empty parenthesis was interpreted as a None, but the second was interpreted as something.
1 Odpowiedź
+ 2
The first condition occurs because the return of just a print() is None. For the second statement, you are assigning foo to (), which in python declares a tuple. So foo is of tuple type and not None type.