Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58015
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Organising packages/modules - importing functions from a common.py in a separate directory? |
| Date | 2013-10-30 10:48 +0100 |
| Organization | None |
| References | (3 earlier) <mailman.1734.1383008475.18130.python-list@python.org> <c178efff-259c-4823-85c4-864ce7534cdf@googlegroups.com> <ebf28078-c0a5-4ba5-ae95-59efe15c98e4@googlegroups.com> <mailman.1746.1383032663.18130.python-list@python.org> <306e0965-cc83-43e0-bfa1-cd9761bcbfff@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1798.1383126486.18130.python-list@python.org> (permalink) |
Victor Hooi wrote:
> Wait - err, subpackage != module, right? Do you think you could explain
> what a sub-package is please? I tried Googling, and couldn't seem to find
> the term in this context.
In analogy to subdirectory I em_load and pg_load -- and common if you add an
__init__.py would be sub-packages, provided only the parent of foo_loading
is in sys.path and you import them with
import foo_loading.pg_load
etc.
> Also, so you're saying to put the actual script that I want to invoke
> *outside* the Python package.
>
> Do you mean something like this:
>
>> sync_em.py
>> sync_pg.py
>> foo_loading/
>> __init__.py
>> common/
__init__.py
>> common_foo.py
>> em_load/
>> __init__.py
>> config.yaml
>> em.py
>> pg_load/
>> __init__.py
>> config.yaml
>> pg.py
>
> and the sync_em.py and sync_pg.py would just be thin wrappers pulling in
> things from em.py and pg.py? Is that a recommended approach to organise
> the code?
I don't know. I prefer it that way.
> Would it make any difference if I actually packaged it up so you could
> install it in site-packages? Could I then call modules from other modules
> within the package?
If you mean "import", yes, installing is one way to get it into sys.path.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-10-28 14:12 +0100
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Victor Hooi <victorhooi@gmail.com> - 2013-10-28 17:51 -0700
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Ben Finney <ben+python@benfinney.id.au> - 2013-10-29 12:01 +1100
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Victor Hooi <victorhooi@gmail.com> - 2013-10-28 18:08 -0700
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Victor Hooi <victorhooi@gmail.com> - 2013-10-28 23:58 -0700
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Peter Otten <__peter__@web.de> - 2013-10-29 08:44 +0100
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Victor Hooi <victorhooi@gmail.com> - 2013-10-29 12:39 -0700
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Peter Otten <__peter__@web.de> - 2013-10-30 10:48 +0100
Re: Organising packages/modules - importing functions from a common.py in a separate directory? Peter Otten <__peter__@web.de> - 2013-10-30 11:23 +0100
csiph-web