0

python dict question: what's behind "{...}"?

trying to play around with dict: >>> dic = {'a':1} >>> dic['b'] = dic >>> print(dic['a']) 1 >>> print(dic) {'a': 1, 'b': {...}} >>> print(dic['b']) {'a': 1, 'b': {...}} so, what's {...}? is it abbrevated list of {'a': 1, 'b': {{'a': 1, 'b': {{'a': 1, 'b': {...}}...}}...}}?

23rd Sep 2019, 1:12 AM
Yenan Zhu
Yenan Zhu - avatar
2 ответов
+ 1
Interesting question. It means that you created an infinite dictionary nested inside itself, which can't be printed. "dic" contains "dic" which contains "dic"... and so on. The "{...}" notation is a way to let you know this, and to inform that it can't be represented. Slightly modified answer taken from https://stackoverflow.com/questions/17160162/
23rd Sep 2019, 2:26 AM
Diego
Diego - avatar
+ 1
thanks Diego! and the link worths clicking!
25th Sep 2019, 5:14 PM
Yenan Zhu
Yenan Zhu - avatar