On Sat, Sep 11, 2010 at 9:26 PM, cool-RR <[email protected]> wrote:
> On Sat, Sep 11, 2010 at 9:23 PM, Amit Aronovitch <[email protected]>wrote: >> >> Good question, that would indeed be bad to use short_mod.Bar as a name >>> for Foo. But the way I do my shortening does not allow for something >>> like this to happen. (I have not mentioned this in my original message, >>> sorry.) The shortening can only remove components from the address. So an >>> address like a.b.c.d.e can be shortened to a.c.d.e or a.d.e but not >>> x.y.z. So I think this prevents these kinds of problems from happening. >>> >> >> Also certainly simpler than searching all of sys.modules. >> Point to consider (at the risk of being trivial): you probably want to >> consider only the "exported" names (stuff in __all__ ) to avoid accidental >> shortenings of names that were imported for internal use by a parent module >> (and might disappear from dir() if the implementation changes). >> >> AA >> > > Good idea, I'll put it in a #todo. (It's not needed for my use, but would > be good to add.) > > > Ram. > Hello all, I released the `address_tools` module which does exactly what I asked for: https://github.com/cool-RR/GarlicSim/tree/master/garlicsim/garlicsim/general_misc/address_tools Here are its tests<https://github.com/cool-RR/GarlicSim/tree/master/garlicsim/test_garlicsim/test_general_misc/test_address_tools> . You can use it by installing `garlicsim` and doing `from garlicsim.general_misc import address_tools`. Its main functions are `describe` and `resolve`, which are parallel to `repr` and `eval`. The docstrings explain everything about how these functions work. There is even a Python 3 version on the Python 3 fork of GarlicSim<http://pypi.python.org/pypi/garlicsim_py3>. So you can use it on Python 3 code. Enjoy, Ram.
_______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
