Dieter Maurer <die...@handshake.de> wrote: > You can create a tuple in "C" and then put a reference to itself into > it, but I am quite convinced that you cannot do it in Python itself. > (Of course, you could use "cython" to generate C code with a source > language very similar to Python).
I don't think you can even do it in C without breaking the specified API: PyTuple_SetItem fails if the reference count of the tuple is not 1, but it also steals the reference of the object that is being added to the tuple so if you don't increment the reference count before attempting to add the tuple to itself you've broken the rules for reference counting. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list