I thought that displaying in Python interactive mode is always equivalent print(repr()), but this is not the case for None. Is this a linguistic function or am I missing something? Thanks you
print(repr())
None
>>> None >>> print(repr(None)) None >>>
Yes, this behavior is intentional.
From Python Docs
7.1. Expression Operators( ) (), (, ; Python, None). . :expression_stmt ::= starred_expression ( )., None, string repr() ( , None, .)
7.1. Expression Operators
( ) (), (, ; Python, None). . :
expression_stmt ::= starred_expression
( ).
, None, string repr() ( , None, .)
repr()
. python None, .
. , , None, .
, print() None, :
print()
>>> print("hello") hello >>> y = print("hello") hello >>> y >>> print(y) None
Python , , , None. , Python . , "", .
,
>>> a = 1 >>> a 1 >>>
>>> a = None >>> a >>>
None , . - Python, __repr__ ; None .
__repr__
. , , None ( ), , , , print(None) None , print None.
print(None)
print
print(repr()) a TypeError Python.
TypeError
Source: https://habr.com/ru/post/1655477/More articles:MockWebServer Response Delay - Test Timeout - retrofitWhy do I say "cd" when updating Homebrew? - gitdelayed response MockWebServer - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1655475/why-does-homebrew-say-no-git-repository&usg=ALkJrhjDASnIC8qPJwr-AAtJlNjTjxA0ogF # - Do I need to delete ref cells explicitly? - heapSpring RestTemplate & AsyncRestTemplate with Netty4 hangs forever - javaMultiple messages from Xamarin message center when restarting application - c #Visual Studio 2015 Xamarin.Android - restricts access to the image gallery to only one element for each - c #How to choose top salaries for each person? - sqlC ++ Throwing the same error message from different places in the code - c ++All Articles