Small changes in side library

maxim.gavrilov at gmail.com maxim.gavrilov at gmail.com
Sun Sep 23 03:07:27 CEST 2007


Hi, all!

May be this question have been already discussed, but I found nothing
closer :-/
I have the side library which provides wide set of different
functions, but I'm going to replace some of them with mine and
provided such 'modified' library thought my project.

The following way works well for my purpose:

------- mylib.py -------
import sidelib

import os, sys, ....

def func():
    .....
sidelib.func = func
......
?!?!?!?!
--------------------------

But this cause to write mylib.sidelib.func() to function call, is it
any way to 'map' definitions from sidelib to mylib (possible at point
marked ?!?!?!?!) such that constructions like mylib.func() will be
provided and client code don't see difference between changed and
original library in syntax way?

One my idea was to do from sidelib import * and then modify globals()
dictionary, but this isn't good too because mylib imports many other
modules and they all mapped into it's namespace (like mylib.os,
mylib.sys).

Thanks for attention!




More information about the Python-list mailing list