On Mon, Oct 28, 2013 at 2:43 PM, Victor Hooi <victorh...@gmail.com> wrote: > Is it acceptable to use try-except in order to achieve this? E.g.: > > try: > # Try to open up the SQLite file, and lookup the required entries > except OSError: > # Open an empty SQLite file, and create the schema > > > My thinking is that it is (easier to ask forgiveness than permission), but I > just wanted to check if there is a better way of achieving this?
That looks fine as a model, but is OSError what you want to be catching? I'd go with FileNotFoundError if that's what you're looking for - OSError would also catch quite a bit else, like permissions errors. ChrisA -- https://mail.python.org/mailman/listinfo/python-list