Recommendations (or best practices) to define functions (or methods)

vizcayno pretoriano_2001 at
Mon Jan 8 14:25:49 CET 2007

Martin v. Löwis ha escrito:

> vizcayno schrieb:
> > Need your help in the "correct" definition of the next function. If
> > necessary, I would like to know about a web site or documentation that
> > tells me about best practices in defining functions, especially for
> > those that consider the error exceptions management.
> I agree with George Sakkis' remarks. The best way to define this function is
> def ExecuteSQL(cmdSQL, cursor):
>   return cursor.execute(cmdSQL)
> If this raises an exception, it likely means there is something
> wrong with the SQL statement. The program should abort, and the
> developer should correct it.
> Regards,
> Martin

Thanks for your indications.
However, what happens when the error is due to data error. Or when the
program is reading many files to save data into a database and one or
two files have problems with data format. I would like to keep the
program running (using exception in a controlled way) for the remaining
good files and prepare a log about the failed files. How to keep the
same function for a program that runs in batch, or on-line or in  the
web? Giving the simple example I put, I would like to find more

More information about the Python-list mailing list