[IPython-dev] Flat is better than nested
W. Trevor King
wking at tremily.us
Mon May 20 12:26:54 EDT 2013
On Fri, May 17, 2013 at 11:19:47AM -0500, Carlos Córdoba wrote:
> For us in Spyder it would be better to be able to import things like
> RichIPythonWidget as
>
> from IPython.frontend.qt import RichIPythonWidget
>
> instead of
>
> from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
>
> because even without "frontend" there are four levels of nested modules
> to reach one of the most essential pieces of that frontend.
>
> So why not add an __all__ attribute to each frontend instead?
I've just been skimming this thread, but I'd caution against namespace
squashing for scripting things (not very DRY). If users are calling
RichIPythonWidget from their IPython session, then providing a
shortcut namespace is fine (à la Matplotlib's pylab [1]), but having
multiple script-oriented locations is just confusing. In this case,
it might be best to have:
from ._rich_ipython_widget import RichIPythonWidget
in IPython.qt.console (or IPython.qt?), which all consumers have to
use instead of importing the (now private) rich_ipython_widget module
directly.
Cheers,
Trevor
[1]: http://matplotlib.org/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related
--
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130520/55b99324/attachment.sig>
More information about the IPython-dev
mailing list