Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20978
| From | "Frank Millman" <frank@chagford.com> |
|---|---|
| Subject | Re: Question about sub-packages |
| Date | 2012-02-28 14:44 +0200 |
| References | <jii0vo$36t$1@dough.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.226.1330433101.3037.python-list@python.org> (permalink) |
"Frank Millman" <frank@chagford.com> wrote in message news:jii0vo$36t$1@dough.gmane.org... > Hi all > > This is a follow-up to my recent question about circular imports, but on a > different subject, hence the new thread. > [...] > > If this makes sense, my next thought was, where is the best place to put > this API. Then I thought, why not put it in the __init__.py of the > sub-package? Then all that the users of the package have to do is import > the package, and then place calls on it directly. > > I did a quick test and it seems to work. Is this a good idea, or are there > any downsides? > Answering my own question again ... The one-liner API concept *may* be a good idea - still waiting for some feedback on that. But putting them into __init__.py is not a good idea, as I run into some subtle 'circular import' problems again. I don't fully understand the conditions under which it fails, but that is unimportant, as my objective is to avoid circular imports altogether. I have created a module called 'api.py' and put them in there, and that seems to work (for now...). Frank
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Question about sub-packages "Frank Millman" <frank@chagford.com> - 2012-02-28 14:44 +0200
csiph-web