globalwordnet / OMW

The Open Multilingual Wordnet
http://compling.hss.ntu.edu.sg/omw/
MIT License
58 stars 9 forks source link

Refactor query functions with `return` in a for-loop #60

Open goodmami opened 5 years ago

goodmami commented 5 years ago

For example:

    def f_src_id_by_proj_ver(proj, version):
        for r in query_omw("""SELECT src.id 
                              FROM src JOIN proj
                              ON src.proj_id=proj.id 
                              WHERE proj.code= ? AND src.version = ?""",
                           [proj, version]):
            return r['id']

Besides being confusing, it is a source of bugs. In one case (#48), the for loop iterated over an empty list, so the function returned None instead of r['id'].