[Python-ideas] Allow from foo import bar*
Nick Coghlan
ncoghlan at gmail.com
Thu Oct 3 23:44:43 CEST 2013
On 4 Oct 2013 06:01, "Joshua Landau" <joshua at landau.ws> wrote:
>
> On 3 October 2013 19:43, Giampaolo Rodola' <g.rodola at gmail.com> wrote:
> >> Hm. Why not just use "import socket" and then use
"socket.AF_<whatever>"?
> >
> > That's what I usually do as well (because explicit is better than
implicit)
> > but from my understanding when it comes to constants it is generally not
> > considered a bad practice to import them directly into the module
namespace.
> > I guess my specific case is bit different though.
> > I have all these constants defined in a _linux.py submodule which I
import
> > from __init__.py in order to expose them publicly.
> > And this is how I do that:
> >
> > # Linux >= 2.6.36
> > if _psplatform.HAS_PRLIMIT:
> > from psutil._pslinux import (RLIM_INFINITY, RLIMIT_AS,
RLIMIT_CORE,
> > RLIMIT_CPU, RLIMIT_DATA,
RLIMIT_FSIZE,
> > RLIMIT_LOCKS, RLIMIT_MEMLOCK,
> ...
> >
> > In *this specific case* a "from _psplatform import RLIM*" would have
solved
> > my problem nicely.
>
> Or we change the module such that we can do
>
> from psutil._pslinux import RLIMIT
>
> and then use RLIMIT.CORE, RLIMIT.CPU, RLIMIT.LOCKS, etc.
Another Enum candidate, perhaps?
Cheers,
Nick.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131004/bc921772/attachment.html>
More information about the Python-ideas
mailing list