On Mon, May 21, 2012 at 5:38 AM, Nicolas M. Thiery <nicolas.thi...@u-psud.fr> wrote: > Bonjour Vincent! > > On Mon, May 21, 2012 at 11:24:09AM +0200, Vincent Delecroix wrote: >> In particular >> >> sage: sage: module = sys.modules[ZZ.__module__] >> sage: [key for key in module.__dict__ if module.__dict__[key] == ZZ] >> [] > > Here we are lucky enough that we can get the object through its class: > > sage: module = sys.modules[ZZ.__class__.__module__] > sage: [key for key in module.__dict__ if module.__dict__[key] == ZZ] > ['ZZ', 'Z'] > > This seems like a typical use case that such objects are instantiated > in the same module as their class. > > Then, if all else fail, indeed recourse to find/grep (or maybe using > search_src to avoid reimplementing that find/grep?). > > If this fails as well: oh well. import_statements is nothing but a > little interactive convenience; it should work in most cases, but if > it occasionally fails, so be it. If we get really annoyed, we will > improve in a later iteration based on the found counter-examples.
Once the import statement is determined, can we try to evaluate it and raise an error if it doesn't work? This would at least catch syntax errors like this: from sage.rings.rational_field import Rational Field Then we could try the next strategy, and so on. Franco -- -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.