Automatic import ?

Jean-Michel Pichavant jeanmichel at sequans.com
Sat Mar 27 08:42:07 EDT 2010


C. B. wrote:
> [snip]
> It takes time to write the relative importations, that's ok, but I
> think it could be more pleasant for the end-user to not have to write
> a huge list of "from mymodule import xxx" if it is possible to take
> advantage of automatic importations.
>
> Cheers,
>   

In that particular case, replace automatic by implicit, and you got the 
reason why it is not a good idea.
Maybe in your case the C habits clashes to the python habits.

Talking about python, if the user needs to know about BBB, then it has 
to import it, perdiod. If the user needs to know about many objects, 
then it has to import them all, explicitly.
However it looks like all your objects belong to the same module, 
quoting MRAB:

"
Couldn't you just have:

    import mymodule as m

and then use:

    m.AAA
    m.BBB
"


You don't like prefixing your object with the namespace they belong to ? 
Well, you should :o)

JM


PS : I would'n have renamed the module, but that falls into personal 
preferences.



More information about the Python-list mailing list