... but here at PDW we abhor that kind of defeatism!
>>> import ctypes
>>> tup = (None,)
>>> ctypes.pythonapi.PyTuple_SetItem.argtypes = ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p
>>> ctypes.pythonapi.PyTuple_SetItem(id(tup), 0, id(tup))
0
Showing the tuple itself is a little problematic
>>> tup
# ... hundreds of lines of parens ...
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((Segmentation fault
This is not surprising, since C-API is actually used. Without it, making a tuple instance with a part of itself will not possible.
ReplyDeleteyup! only the C-API makes it possible
Deleteit is kind of interesting though that tuple doesn't have any recursion handling in its repr()
>>> a = []
>>> a.append((a,))
>>> a
[([...],)]
>>> a[0]
([([...],)],)
rather than tuple(list(tuple)) showing ([(...,)]) it relies on the list repr() to detect the cycle and handle it one layer deeper
contract with dict(list(dict)) in which the dict repr() detects the cycle
>>> b = {}
>>> b[0] = [b]
>>> b
{0: [{...}]}
Odd; not getting this error under ipython, though I do get it with plain python. Both should(?) be running the same python executable; at any rate both report running 2.7.15 (can't even try this in python3 it seems). But under ipython I just get ((...),) as one might expect.
ReplyDeleteI have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog! 统计代写
ReplyDeleteAmazing Article,Really useful information to all So, I hope you will share more information to be check and share here.
ReplyDeleteinternship in chennai for electrical engineering students
one month internship in chennai
vlsi internship in chennai
unpaid internship in chennai
internship for hr in chennai
internship training chennai
internship for freshers in chennai
internship in chennai for it students with stipend
internship in accenture chennai
naukri internship in chennai
It was worthy experience to get some answers concerning hazardous complement. Valuable for everyone looking with respect to the issue.
ReplyDeletedata scientist course in delhi
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDeletebusiness analytics course