How to import only one module in a package when the package __init__.py has already imports the modules?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Nov 1 06:43:11 CET 2009


On Sat, 31 Oct 2009 22:54:47 -0500, Peng Yu wrote:

> So python would not be able to accommodate my preference one
> class/function per file? 

Of course it does! You can do that RIGHT NOW -- just put one class per 
file.

> I.e., I have to use something like 'from spam
> import spam' or 'spam.spam()', 

How else do you expect to use the class if you don't import it?


> or accept that the filename is not the
> same as the class/function name.

So let me see... 

You don't want to write "import spam; spam.spam()"
You don't want to write "from spam import spam; spam()"
You don't want to write "from Spam import spam; spam()"
You don't want to write "from spam import Spam; Spam()"

What exactly do you want?




-- 
Steven



More information about the Python-list mailing list