[Python-il] Fwd: Is there a Python module for handling Python object addresses?

cool-RR cool-rr at cool-rr.com
Fri Dec 24 00:29:41 IST 2010

On Sat, Sep 11, 2010 at 9:26 PM, cool-RR <cool-rr at cool-rr.com> wrote:

> On Sat, Sep 11, 2010 at 9:23 PM, Amit Aronovitch <aronovitch at gmail.com>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:


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
So you can use it on Python 3 code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://hamakor.org.il/pipermail/python-il/attachments/20101224/637d0c29/attachment.htm>

More information about the Python-il mailing list