print("Line 1")
print(">>>")
type(print("Hello"))
print()
print("Line 2")
print(">>>")
print(print("Hello"))
print()
print("Line 3")
print(">>>")
a = print("Hello")
b = a
print("a:", a, "b:", b)
Q1) For Line 1, why is it that type(None) not be executed since print("Hello") returns None ?
Q2) I am sort of aware that IIFE is a term usually associated with JavaScript but I am wondering why Python's print() function seems to display certain IIFE properties like running a function the moment it is invoked (as seen in the output for Line 3) ?
Below is the output for the code above (for Python 3.9):
Line 1
>>>
Hello
Line 2
>>>
Hello
None
Line 3
>>>
Hello
a: None b: None
this(that())
will invokethat
and then invokethis
in basically any language. Andprint
is just a function like any other function, absolutely nothing special about it. You seem to misunderstanding what an IIFE is entirely.print
does not return anything, but writes to the output buffer. Soa = print("Hello")
did not do what you probably thought it would, in the first place.type(print("Hello"))
is certainly invoked but please explain to use why you would expect anything to show up as a result of it!