Developing Techniques (and naming conventions)

Adekoba adekoba at gmail.com
Sun Feb 24 15:27:55 EST 2008


On Feb 24, 3:21 pm, Jeroen Ruigrok van der Werven <asmo... at in-
nomine.org> wrote:
> -On [20080224 20:01], Adekoba (adek... at gmail.com) wrote:
>
> >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?
>
> import food
>
> Which in turn has something like this in food/__init__.py:
>
> from food.cheese import gouda
> from food.ham import parma
>
> __all__ = ['gouda', 'parma']
>
> and in turn in your script you can now use food.gouda and food.parma.
>
> Unless I totally misunderstood what you are trying to achieve.
>
> --
> Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
> イェルーン ラウフロック ヴァン デル ウェルヴェンhttp://www.in-nomine.org/|http://www.rangaku.org/
> We have met the enemy and they are ours...

I was just curious if I could get a script name to be the same name as
the package directory, but apparently it is not possible. Instead I
think I am going to do something like:

setup.py
food/
      __init__.py
      ham.py
      cheese.py
scripts/
      food

and just set my PYTHONPATH to the parent directory. I have never done
a full scale project before in python, but I think this is probably on
track with what most people would do.



More information about the Python-list mailing list