Skip to content

Minor cosmetical and readability suggestions

A few tips for code organisation:

  1. Between functions, keep two empty lines to make the code more readable (avoid https://gitlab.idiap.ch/bob/bob.db.drive/blob/master/bob/db/drive/query.py#L37)
  2. If a class has no inheritance, just say class X instead of class X() (avoid https://gitlab.idiap.ch/bob/bob.db.drive/blob/master/bob/db/drive/query.py#L14)
  3. Instead of explicitly using open/close constructs in Python, use with (as with with open(db_json,'r') as f: #use f). That makes your code more readable and safe, as the file will always be closed no matter what happens, even if any of the lines within that context raise an exception! No need to close the file with with, it is done automagically for you.