Richard Brodie wrote:
"Stefan Behnel" <stefan...@behnel.de> wrote in message news:4a008996$0$31862$9b4e6...@newsspool3.arcor-online.net...

   language_map = {'English': 'EN', 'Deutsch': 'DE'}
   strict_or_transitional = {True: 'Transitional', False: 'Strict'}

   # this will raise a KeyError for unknown languages
   language = language_map[ self.cmboBoxLang.currentText() ]

   # this assumes that isChecked() returns True or False
   spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()]

   doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 %s/%s">\n' % (
       spec, language)

Incidentally, the language in an HTML DOCTYPE refers to the language of the 
DTD, not
the document. It's never correct to use //DE in an HTML page, unless you have a 
custom
(German) DTD. So the code can be improved further by cutting that part out.

    strict_or_transitional = {True: 'Transitional', False: 'Strict'}

    # this assumes that isChecked() returns True or False
    spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()]

    doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 %s//EN">\n' % spec




Yes, that's true. I missed that. Thanks for the information.
And many thanks to Stefan.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to