I'm working with an instance of a Python logger.


Some code:



log = 
logging.basicConfig(level=logging.DEBUG,filename="/home/richard/templog",filemode='w')



Later in my program I do:

log.info("finished step 4.")



Python spits out this error:



Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

AttributeError: 'NoneType' object has no attribute 'info'

I CAN, however, do:
logging.info("finished step 4.")

And it works.



What confuses me about this is that I can do something like this:



# call another function and pass it the logger instance:

foo(logging)



And, if I define foo() like this:



def foo(log):

   # this works fine!

   log.info("finished step 4.")



The log.info works fine inside of foo().



Why is it that I can pass logging as an instance into a function, and
use whatever instance name I wants inside of foo(), but I can't assign
an "alias" for the logging instance inside of main() (by doing instancealias = 
logging.basic())?

/r





       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for 
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to