Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20978 > unrolled thread

Re: Question about sub-packages

Started by"Frank Millman" <frank@chagford.com>
First post2012-02-28 14:44 +0200
Last post2012-02-28 14:44 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Question about sub-packages "Frank Millman" <frank@chagford.com> - 2012-02-28 14:44 +0200

#20978 — Re: Question about sub-packages

From"Frank Millman" <frank@chagford.com>
Date2012-02-28 14:44 +0200
SubjectRe: Question about sub-packages
Message-ID<mailman.226.1330433101.3037.python-list@python.org>
"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


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web