On Wed, Mar 11, 2009 at 12:11 PM, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: >> Then "x in P" means that there is a safe conversion from the parent of >> x to P. If this is actually a coercion, then you don't even have to >> run it; if it's a conversion, then you do have to run it, to test that >> the conversion is defined on x. "x == y", "x<y" will find a safe >> coercion to a common parent if one exists; otherwise it will find a >> safe conversion. If a conversion is used that fails, then the >> comparison is false. > > This preceding rule is not always true: I know many counter example. > To begin with > > sage: x = int(2) > sage: type(x) > <type 'int'> > > Of course x has no parent: > sage: x.parent() > ... > AttributeError: 'int' object has no attribute 'parent' > sage: x in ZZ > True > > So your rule "there is a safe conversion from the parent of x to P" does not > specify why we should answer yes. I fill being some lawyer in pointing out > that but I think we must use extra care when using conversion/coercion from > basic type to construct elements. > > Another example to show that the example is not as trivial as it seem: > > sage: l = [3,2,1] > sage: l in Permutations() > True > sage: l in Partitions() > True > > Cheers, > > Florent
The paragraph you quoted was part of a very rough proposal for a way that Sage's coercion might be changed in the future; it's definitely not how it works now. Also, the way coercion is implemented now, int(2) does have a parent; it's just not available at the .parent() method: sage: parent(int(2)) <type 'int'> Carl --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---