How to replace the metaclasses of all the classes imported
mertz at gnosis.cx
Wed Jun 4 00:01:47 CEST 2003
janeaustine50 at hotmail.com (Jane Austine) wrote previously:
|I know of import_with_metaclass at
|http://gnosis.cx/download/gnosis/magic/__init__.py but it doesn't help
|Say, I have a module A which imports module B with an ordinary
|"import" statement. With import_with_metaclass I can replace the
|metaclasses of all the classes in module A, but not those from B.
I'm sure I could work this out with a little trial-and-error. You can
check which of the names in A are modules, and recurse from there. I'd
want to play with it, and run a few test cases to make sure I got the
details right (for example, what about import diamonds and circular
I cannot promise I'll add this to gnosis.magic on any particular time
schedule. But if you work out the details yourself, I'd love it if you
would contribute your code for inclusion in the public domain Gnosis
Utilities. Since I made a start at including some useful metaclass
functions there, it would make sense to add more in the same place, IMO.
Actually, the same goes for anyone, not just Austine.
Keeping medicines from the bloodstreams of the sick; food from the bellies
of the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons. Intellectual
property is to the 21st century what the slave trade was to the 16th.
More information about the Python-list