[Chicago] from x import * but reference it by x.myfunc?

Lukasz Szybalski szybalski at gmail.com
Mon Apr 28 16:54:02 CEST 2008


On Mon, Apr 28, 2008 at 9:37 AM, Adam Jenkins <emperorcezar at gmail.com> wrote:
> I think you would just
>
> import x
>
> and that should let you use x.afunc(), etc.

That is what I was using.

Actually, I guess I will stick with import x but what is the proper
way to pass the loging module ?

mainfile.py
-------------------------------------
import logging

logging.basicConfig()

log = logging.getLogger("MyApp")
log.setLevel(logging.DEBUG) #set verbosity to show all messages of
severity >= DEBUG
#log.setLevel(logging.INFO) #set verbosity to show all messages of
severity >= DEBUG
log.info("Starting my app")

....code...
import x
...more code....
----------------------------------------
In mainfile.pyI can do log.warn('warning')

How do I use loging in file x.py?

x.py
-----------------------
....code...
log.warn('warning')
....code........
-----------------------

Doesn't know what log is. Do I have to reimport it in x.py or setup
global variable log, or ?

Lucas


More information about the Chicago mailing list