On 6/15/10 9:03 AM, genkuro wrote:
> 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?

The only way to refer to anything is by its name -- or, from a name and
through subscript/dot notation if you've stored something in a container.

But a package (and anything else) can have many names, and it really has
no idea what they are.

You can do "import logging as logging_package" which is just a shortcut for:

    import logging
    logging_package = logging
    del logging

And such.

That said: The frameworks I've seen that shadow the global 'logging'
package with a specific logger do so somewhat on purpose (though I find
the practice slightly dubious), so that naive code which previously just
used the general root logger would work with the more specific one
seamlessly.

But such frameworks usually also have a setup/environment sort of file
where this is not done, and that's where things like adding handlers
belongs.

Just as an aside.

Renaming "logging = ..." to "logger = ..." is probably a better solution
anyways :)

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to