[Tutor] Query about getattr used as a dispatcher

raghu raghu vgvr620034 at gmail.com
Wed Jan 17 13:58:53 CET 2007


i am following 'dive into python' for learning. i come across a term
getattr() which gives reference about a function.Its written it can be used
as a dispatcher. Below example given for that builtin function:
import statsout
  def output(data,format='text'):
        output_function = getattr(statsout,"output_%s"  % format)
        return output_function(data)
Actually i installed python 2.5 i ran this script and its showing error it
could not import statsout.why is it so?could any one explain this script
briefly. i dont know whether i am following the right book. as i am a
beginner is it right  to follow this book?or is there any other book which
is best for beginners?

-- 

                                           Vanam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070117/672e59bf/attachment-0001.htm 


More information about the Tutor mailing list