How to "generalize" a function?

Alexander Schmolck a.schmolck at gmx.net
Sun Apr 24 19:25:18 EDT 2005


Thomas Köllmann <koellmann at gmx.net> writes:

>     confFile.close

You want ``confFile.close()`` -- the above won't do anything [1].

'as


Footnotes: 
[1]  Best practice would be something like this (don't worry to much about it
     -- it just ensures the file is properly closed, even if something goes
     wrong):

        confFile = None
        try:
            confFile = open(networkConf, 'w')
            confFile.writelines(conf)
        finally:
            if confFile: confFile.close()

    







More information about the Python-list mailing list