Developing Techniques (and naming conventions)
Steve Holden
steve at holdenweb.com
Sun Feb 24 16:44:16 EST 2008
Adekoba wrote:
> On Feb 24, 1:06 pm, Christian Heimes <li... at cheimes.de> wrote:
>> Adekoba wrote:
>>> food.py
>>> food/
>>> __init__.py
>>> ham.py
>>> cheese.py
>>> where food.py is a script that uses the package food. Is it possible
>>> for this to work in any way? Every time I try to run food.py, python
>>> tries to import everything from the script instead of from the
>>> package. How can I fix this?
>> Move the code from food.py to food/__init__.py. You can't have a package
>> and a module with the same name.
>>
>> Christian
>
> So it is not possible?
>
> I don't think moving food.py's code to __init__.py would work out to
> well, because then how would I run the script?
You run food/__init__.py with the following statement:
import food
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list