Re: embarrassing class question
- From: Brendan <brendandetracey@xxxxxxxxx>
- Date: Fri, 22 Oct 2010 05:11:54 -0700 (PDT)
On Oct 22, 5:02 am, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.au> wrote:
On Thu, 21 Oct 2010 12:12:34 -0700, Brendan wrote:
Because y.py has "from x import x" the x class from x.py is added to
the y.py namespace.
~Ethan~- Hide quoted text -
- Show quoted text -
So what is usually done to prevent this? (In my case not wanting class x
added to the y.py namespace)
It seems sloppy.
(1) Don't import it in the first place.
(2) Import it with a different name, possibly private:
from module import x as _x
(3) Delete it when you're done:
from module import x
class Y(x):
pass
del x
(4) Don't be so fussy and just accept that importing adds names to the
namespace, as does any other assignment or class or function definition.
--
Steven
I'll take (2) and pass on (4)
Thanks
.
- References:
- embarrassing class question
- From: Brendan
- Re: embarrassing class question
- From: Ethan Furman
- Re: embarrassing class question
- From: Brendan
- Re: embarrassing class question
- From: Steven D'Aprano
- embarrassing class question
- Prev by Date: Re: functions, list, default parameters
- Next by Date: Re: Re: embarrassing class question
- Previous by thread: Re: embarrassing class question
- Next by thread: Re: Re: embarrassing class question
- Index(es):
Relevant Pages
|