Newbie: import

2007-04-18 Thread genkuro
I thought import used relative paths from either the python executable
or the script being executed.  I have a script pulling in code from an
arbitrary directory.  How is this happening?

It's a RHEL 4 environment by the way.  I couldn't find any relevant
environment variables.

Thanks from a newbie for any insight.

-- 
http://mail.python.org/mailman/listinfo/python-list


logging = logging.getLogger(__name__)

2010-06-15 Thread genkuro
Newbie here.  I may be missing something obvious, in which case,
please feel free to berate and laugh at me.

Here's a dubious line of code:
logging = logging.getLogger(__name__)

How can I refer to the original logging package "logging" after this
statement is run?  Specifically, I'm trying to add a log handler with
logging.addHandler(x) and it is of course failing.

Thanks,
Brian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging = logging.getLogger(__name__)

2010-06-15 Thread genkuro
On Jun 15, 8:49 am, Mark Lawrence  wrote:
> On 15/06/2010 16:35, genkuro wrote:
>
> > Newbie here.  I may be missing something obvious, in which case,
> > please feel free to berate and laugh at me.
>
> > Here's a dubious line of code:
> > logging = logging.getLogger(__name__)
>
> > How can I refer to the original logging package "logging" after this
> > statement is run?  Specifically, I'm trying to add a log handler with
> > logging.addHandler(x) and it is of course failing.
>
> > Thanks,
> > Brian
>
> Change it to something like logger = logging.getLogger(__name__), then
> logger.addHandler(x).  If you don't do this, your logging shadows the
> logging module so you won't get very far.
>
> HTH.
>
> Mark Lawrence

Hi Mark -

I thought that would be the answer.

I asked because I'm working with a framework where logging is
similarly renamed in almost every file.  The framework is under
development so refactoring is an option.

I'm coming to Python from Java.  I'm still getting a feel for scoping
limits.  For the sake of curiosity, is there another way to refer to a
package besides name?

Thanks,
Brian

-- 
http://mail.python.org/mailman/listinfo/python-list