How to import only one module in a package when the package __init__.py has already imports the modules?
pengyu.ut at gmail.com
Sun Nov 1 15:13:11 CET 2009
On Sat, Oct 31, 2009 at 11:43 PM, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
> 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
>> 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?
When I define class spam in file spam.py, I want to call it by
If spam.py is in dir/, then I want to call it by
More information about the Python-list