Reputation: 1
I always think that google colab just print (by default the end edgy var) the var in the last line but came with this unexpect output that is different from print() function. Anyone can explain why this happens?
Dont know why came two differents output
Upvotes: 0
Views: 1157
Reputation: 4099
Pretty printing is enabled by default. The pretty print for classes and types seems to be determined by _type_pprint() and you can see that it can be the module and name:
p.text(mod + '.' + name)
You can toggle pretty printing on/off using the %pprint
line magic. Example with the outputs as comments:
class Foo:
pass
print(Foo)
# <class '__main__.Foo'>
Foo
# __main__.Foo
%pprint
# Pretty printing has been turned OFF
Foo
# <class '__main__.Foo'>
With the pretty printing off the output seems to be the same as the __repr__
.
Upvotes: 1