Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57790
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'model,': 0.05; 'schema': 0.05; 'lookup': 0.09; 'permissions': 0.09; 'try:': 0.09; '(easier': 0.16; 'forgiveness': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oserror': 0.16; 'sqlite': 0.16; 'subject:flow': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'else,': 0.19; 'file,': 0.19; 'this?': 0.23; 'entries': 0.24; 'errors.': 0.24; 'fine': 0.24; 'mon,': 0.24; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'quite': 0.32; 'open': 0.33; "i'd": 0.34; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'acceptable': 0.36; 'achieving': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'catch': 0.60; "you're": 0.61; 'victor': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DWFy79gQ+fr9C01ARp9ZfwddFPOI+HuHsdfsuFoIZXo=; b=zFwJTQSVZKix3ufNdEGCpujZzoGSIsmNXrXhChYXUcKkO6yxBM7bsBLBok4NnMy6ex 5IrX8GG6tQ8atdKsw04dvkGigz5k0JaX5AZtbCrdebRIwHN9ToXNHYZN+lLs67BdqbEk 2Ffu76fVMURGF33kDI7LOqh8sQuB0tIClW+eXLlMKsP4J3AzyTxwxrPjaPznn92uOAzt 0XUw8SQYsMBS8UKlqumn5wYkOjW71l3jG4VOmgYCQOKxAtdLu2k3u8kQ6a80OL2BE5Sm 2SN3y2rf/nlSJ7h87tKQEzsMrcV0kQP+hgr6ns9mtXsyEdMcc3ZpRVI/ovFP/FvU7TBd vMGA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.170.225 with SMTP id ap1mr14704592pbc.117.1382942165296; Sun, 27 Oct 2013 23:36:05 -0700 (PDT) |
| In-Reply-To | <ac7cf18f-d4f4-41ef-966d-a35d2d0e39a8@googlegroups.com> |
| References | <ac7cf18f-d4f4-41ef-966d-a35d2d0e39a8@googlegroups.com> |
| Date | Mon, 28 Oct 2013 17:36:05 +1100 |
| Subject | Re: Try-except for flow control in reading Sqlite |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1677.1382942174.18130.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1382942174 news.xs4all.nl 15915 [2001:888:2000:d::a6]:38937 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:57790 |
Show key headers only | View raw
On Mon, Oct 28, 2013 at 2:43 PM, Victor Hooi <victorhooi@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-27 20:43 -0700
Re: Try-except for flow control in reading Sqlite Steven D'Aprano <steve@pearwood.info> - 2013-10-28 06:18 +0000
Re: Try-except for flow control in reading Sqlite Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-28 10:48 +0100
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 17:36 +1100
Re: Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-27 23:57 -0700
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 18:01 +1100
Re: Try-except for flow control in reading Sqlite Steven D'Aprano <steve@pearwood.info> - 2013-10-28 07:19 +0000
Re: Try-except for flow control in reading Sqlite Chris Angelico <rosuav@gmail.com> - 2013-10-28 18:02 +1100
Re: Try-except for flow control in reading Sqlite Burak Arslan <burak.arslan@arskom.com.tr> - 2013-10-28 10:17 +0200
Re: Try-except for flow control in reading Sqlite Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-28 19:43 -0400
Re: Try-except for flow control in reading Sqlite Victor Hooi <victorhooi@gmail.com> - 2013-10-31 16:08 -0700
Re: Try-except for flow control in reading Sqlite Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-31 22:45 -0400
csiph-web