Is there a trac-ticket for the behaviour of the code [1] for
FiniteEnumeratedSets? The __iter__ function is called twice when
creating a list (or a tuple). This shouldn't be; there is only a warning
given in the docstring of .list().

Daniel

[1] Copied from a warning in sage/categories/finite_enumerated_sets.py:

                Let's take an example::

                    sage: class Example(Parent):
                    ...       def __init__(self):
                    ...           Parent.__init__(self, category =
FiniteEnumeratedSets())
                    ...       def __iter__(self):
                    ...           print "hello!"
                    ...           for x in [1,2,3]: yield x
                    sage: C = Example()
                    sage: list(C)
                    hello!
                    hello!
                    [1, 2, 3]
                    sage: list(C)
                    hello!
                    [1, 2, 3]

                Note that ``hello!`` actually gets printed twice in
                the first call to ``list(C)``. That's because of the
                current (dubious) implementation of
                :meth:`Parent.__len__`.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to