Title: how deque of python print all items
Tags: python
Question: When I print deque object, all items are displayed. This is fine because I wanted to display all items But I was thinking object reference info will be displayed as below in this senario.
Question: How can you identify print(q) display all items by definition in deque source code
I just want to know the reason and which source code allow print(q) to display deque([1]) instead of <__main__.~ object at 0x~~~~~~~8&gt;
I dont mean I want to display <__main__.~ object at 0x~~~~~~~8&gt;
from collections import deque
q = deque()
q.append(1)
print(q)
# Actual output          :  deque([1])
# Output in my mind(which I imagined)  :  <__main__.~ object at 0x~~~~~~~8&gt;
Comment: Does this answer your question? [How can we get the default behavior of \_\_repr\_\_()?](https://stackoverflow.com/questions/48777014/how-can-we-get-the-default-behavior-of-repr)

Comment: it IS the answer to that question. deque has a custom `__repr__`, if you dont define one the default one prints what you expect

Comment: when you try to print a class it will try to print the classes `__str__` and if that doesnt exist it will print the classes `__repr__` which defaults to what you mentioned. if you want just the number then you can get it with `id(q)` which will return the same number you see(but in decimal format instead of hexadecimal). you can read more about [__repr__](https://docs.python.org/3/reference/datamodel.html#object.__repr__) in the docs

Comment: NO, My question is why actual deque value is print out  like my example I just want to know the reason and which sourc code allow `print(q)` to display `deque([1])` instead of ``.  I dont mean I want to display ``

Comment: you are saying when I print out `print(q)`, It displays `` as a default ???

Comment: I just want to confirm again,,,,,, When I print(q) in my example, It displayed `deque([1])`,,,,,,,  NOT ``,,,,,,, Do you understand this right?

Comment: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/226975/discussion-between-kazu25-and-nullman).



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:01/07/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python>', 'Title': 'how deque of python print all items', 'ViewCount': 31, 'id': 65611598, 'user_AboutMe': None, 'user_AccountId': 13448738.0, 'user_DisplayName': 'Kazu25', 'user_Reputation': 67.0, 'user_Views': 31.0, 'user_id': 10145453.0}}