thc v0.3 - txt to html converter - better code?

Florian Wollenschein Florian.Wollenschein at FernUni-Hagen.de
Tue May 5 12:34:17 EDT 2009


Hi all,

here's some code of thc, my txt to html converter programmed with Python 
and pyQT4:
-------------------------------------------------------------------------------
if self.rdioBtnTransitional.isChecked():
             if self.cmboBoxLang.currentText() == "English":
                 file_open.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD 
HTML 4.0 Transitional//EN">' + '\n')
             elif self.cmboBoxLang.currentText() == "German":
                 file_open.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD 
HTML 4.0 Transitional//DE">' + '\n')
         else:
             file_open.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.0 Strict//EN">' + '\n')
             if self.cmboBoxLang.currentText() == "English":
                 file_open.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD 
HTML 4.0 Strict//EN">' + '\n')
             elif self.cmboBoxLang.currentText() == "German":
                 file_open.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD 
HTML 4.0 Strict/DE">' + '\n')
--------------------------------------------------------------------------------

Do you have any ideas for a better code than that? Could this be done 
smarter, shorter, whatever!?

Thanks in advance,
Listick
http://www.listick.org



More information about the Python-list mailing list