Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.068 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.02; 'assignment': 0.07; 'builtin': 0.09; 'try:': 0.09; 'valueerror:': 0.09; 'block.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'language': 0.16; 'wrote:': 0.18; 'separate': 0.22; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'except': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'no.': 0.61; "you're": 0.61; 'name': 0.63; 'different': 0.65; 'effectively': 0.66; 'jul': 0.74; 'absolutely': 0.87; '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=HVmbLa+8om2CNmTwgxvlTbxu0+KvoLv8JWjtk/Km24s=; b=fBC+5J6USEIBlEwAJdy+17dqLvoRu19wI5wh5hi0Co0W4kj7ywFFNfVZtDTFbaSbTk J2HG3xpnawhMqMijRT5NzIUvnEphl8a9nTjWq9noVVQ6A9zKpbSBU5gi/MO24e+Wzrq7 bH1ig+vf0ZJIXHSTATrE2qNn9SuqkjDZRytTN3qz1kKjXgZkehPi3e1skgDF/oYpiXbc duLyZ0K7Oc9W8IXWZpsrPI4NCl0XZLm1SNH5Wjtu/zQjJGzcCh7vKBIKDMDCB0ZL8zaO 29hXm66x88F2+dhNdEovtuMpb2neqRLxLPSgIOwG/+WFao5YQ05eTlTOQwMEVo5YAHlG S58g== MIME-Version: 1.0 X-Received: by 10.66.123.1 with SMTP id lw1mr25781663pab.177.1373346449494; Mon, 08 Jul 2013 22:07:29 -0700 (PDT) In-Reply-To: References: <51d4eb9c$0$29999$c3e8da3$5496439d@news.astraweb.com> <51d508ed$0$6512$c3e8da3$5496439d@news.astraweb.com> <51d5a504$0$29999$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 9 Jul 2013 15:07:29 +1000 Subject: Re: Default scope of variables From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373346452 news.xs4all.nl 15946 [2001:888:2000:d::a6]:43665 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50202 On Tue, Jul 9, 2013 at 2:52 PM, alex23 wrote: > with new_transaction(conn) as folder_tran: > folder_tran.query("blah") > with folder_tran.subtransaction() as file_tran: > file_tran.query("blah") > with file_tran.subtransaction() as type_tran: > type_tran.query("blah") Warp my code around a language limitation? Only if I absolutely have to. The subtransactions are NOT concepted as separate transactions. They are effectively the database equivalent of a try/except block. Would you want to have to use a different name for a builtin just because you're inside a try block? a = int("123") try: b = int1(user_input) except ValueError: b = 0 c = int("234") No. That assignment to b should be int(), same as a and c. ChrisA