Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109214
| From | Gerald Britton <gerald.britton@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Package setup best practice style question |
| Date | 2016-05-28 12:15 -0400 |
| Message-ID | <mailman.9.1464452134.1839.python-list@python.org> (permalink) |
| References | <CAPxRSnZKXLxx850ysMuOHxGs-E1oepCLta8YxGuO7+NHypJ7fg@mail.gmail.com> |
suppose I have a simple python project setup like this:
Project diectory
prog.py
pkg directory
__init__.py
mod1.py
class A:
In order to have class A (unqualified) available from prog.py, there are a
few options that I know about. I'm currently considering two of them and
would like some feedback on best practices.
1. in pkg.__init__.py add:
from pkg.mod1 import A
in prog.py add:
from pkg import A
2. leave __init__.py empty
in prog.py add:
from pkg.mod1 import A
Is there a preference or best practice that would indicate to prefer method
1 or method 2? Are there methods 3, 4, 5, ... that I should consider that
are even better?
--
Gerald Britton, MCSE-DP, MVP
LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Package setup best practice style question Gerald Britton <gerald.britton@gmail.com> - 2016-05-28 12:15 -0400
Re: Package setup best practice style question Steven D'Aprano <steve@pearwood.info> - 2016-05-29 03:00 +1000
Re: Package setup best practice style question Steven D'Aprano <steve@pearwood.info> - 2016-05-29 13:02 +1000
csiph-web