Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'propagate': 0.09; 'thrown': 0.09; 'throws': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'bit.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'messy': 0.16; 'subject:programming': 0.16; 'throw': 0.16; 'url)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'java': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'though.': 0.31; 'skip:_ 10': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'ensure': 0.60; 'catch': 0.60; 'up,': 0.60; 'new': 0.61; 'course': 0.61; "you're": 0.61; 'mar': 0.68; 'thing,': 0.91; 'to:none': 0.92 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:cc :content-type; bh=E3JLvOGQJSo47vLO8BTyrMO9tweG3oVqawnHOcWM+lg=; b=HitZhtBqweDhaPS3rNNMpfcKzV8o8EGhmtO1W6l03/Lv8WXXWh9VOw4Ul6vIpACTyU SDL2cukprdjxd/eliA10cpRJmb1grK2VCOmi42ijCXDlJwAG8lBS52VimO9SidBoLDhH P83ZdYfxYqt8/W0hxsyFf0Ol0bDXpXs+pi+4K0b+VsVRd0/tSmSiZnZ4LLSzdKAAgJdf w4OG6TstW0vM095YbIJ0pl0CHRFY3rBeafR7ETtPyWjb0dWUbFOvwEJVqKF1WHi9CYXC pbXOe6nN7monQPsLF16yBQ9WgLTMsqKBKS/lK9PPe1EnxpIbIQStjcgJl1QZFIeu2e3F P5yA== MIME-Version: 1.0 X-Received: by 10.66.181.70 with SMTP id du6mr1605856pac.23.1393963314841; Tue, 04 Mar 2014 12:01:54 -0800 (PST) In-Reply-To: <87bnxloibq.fsf@elektro.pacujo.net> References: <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> <216bb5f4-32c4-4f86-a9f4-1b0dd37a2a81@googlegroups.com> <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com> <5314bb96$0$29985$c3e8da3$5496439d@news.astraweb.com> <5315661c$0$2923$c3e8da3$76491128@news.astraweb.com> <53159540$0$2923$c3e8da3$76491128@news.astraweb.com> <87bnxloibq.fsf@elektro.pacujo.net> Date: Wed, 5 Mar 2014 07:01:54 +1100 Subject: Re: Functional programming From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393963318 news.xs4all.nl 2956 [2001:888:2000:d::a6]:57317 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67714 On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa wrote: > public ConnectionPool(int maxConnections, String url) throws SQLException { > try { > super(() -> { > try { > return DriverManager.getConnection(url); > } catch ( SQLException ex ) { > throw new WrappedSqlException(ex); > } > }, maxConnections); > } catch (WrappedSqlException wse) { > throw wse.getSqlException(); > } > } > > ===JAVA END============================================================= > > ===PYTHON BEGIN========================================================= > > def __init__(self, max_connections, url): > super().__init__(lambda: DriverManager.get_connection(url), max_connections) You're not doing the same thing, though. The Java rigmarole is to ensure that an SQLException thrown in getConnection will propagate up, despite (presumably) something inside the equivalent of super().__init__ that swallows SQLExceptions. Of course it looks tidier when you don't do the messy bit. ChrisA