[Tutor] Subclassing a module's class.

Francis Moore Francis.Moore at shaws.co.uk
Fri Jul 23 12:08:11 CEST 2004


From: Conrad [mailto:linux-user at softhome.net] 

> class HelpFormatter(optparse.HelpFormatter):
>        def format_option(self, option):
>		print "Hello, World!"

> parser = optparse.OptionParser()
> print parser.print_help

> print_help() in optparse calls the class HelpFormatter. 
> Can anyone explain to me why it doesnt use my HelpFormatter?

Could it be because you haven't overriden print_help() in your 
class? The only function you've overridden is called 
format_option(). Try changing this function to print_help() and 
see if that works.

Cheers,
Francis. 
  
CONFIDENTIALITY NOTICE 
This communication contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (+44(0) 1322 621100) and then delete the e-mail and any copies of it.  
This communication is from Shaw & Sons Limited whose registered office is at Shaway House, 21 Bourne Park, Bourne Road, Crayford, Kent DA1 4BZ. The views expressed in this communication may not be the views held by Shaw & Sons Limited. 
This message has been checked for all known viruses by McAfee VirusScan. 
 


More information about the Tutor mailing list