Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'imported': 0.09; 'raises': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'question.': 0.14; '"assert"': 0.16; '*always*': 0.16; 'module': 0.19; 'seems': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; "doesn't": 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'assert': 0.31; 'received:209.85': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'received:209': 0.37; 'generic': 0.38; 'sure': 0.39; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'side': 0.67; 'safe': 0.72; 'fail.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=J2cLHH3o3XoPSiP39/4s/mxJqrQnt2u8MMdud1qB31w=; b=JWTclwQGZ8WI2rTgewKIivyN4TLqtFnjId3VU2cM4gwize5uZm6QJpsfffmj7SGHjD kaExro9+ql6JoJrAUY5yJnz35XrUgeXjHaWc+RgvnrTP38FwtpTJK3CkIEFh+cciMRqn Y6ZAO3w7T0y0sZNxt79FhJ0ZGvr+/lbxx/at+h1iRdGdfFb4sQrmXHND4w56BK6VmHDu ETZAyl38nxKjZtJ/aDf9yuZYgX5QpTwZYMW8Nl0fqcSIDRfMhbWap7LS8MTezp+Sopsv 5uglggpAEpUeUX+MzceX3p3IyKWmPZWGsxutBPpj7iNqJPYxn6jD5x11JeP1d0UCbhSj 203Q== MIME-Version: 1.0 X-Received: by 10.229.149.12 with SMTP id r12mr5973701qcv.118.1367774864478; Sun, 05 May 2013 10:27:44 -0700 (PDT) In-Reply-To: <20130505164030.GA12637@capricorn> References: <20130505160054.GA10521@capricorn> <20130505164030.GA12637@capricorn> Date: Sun, 5 May 2013 18:27:44 +0100 Subject: Re: How to avoid PEP8 'imported but unused' From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Adam Jiang Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367775216 news.xs4all.nl 15863 [2001:888:2000:d::a6]:45146 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44758 That assert will never fail. If the symbol is not imported, the import statement raises ImportError. And actually "assert" makes sure that the value is not false-ish, not None/Null. And AFAIK a module object is *always* true. > One more question. In this particular case it seems 'assert' should be > safe as a workaround, doesn't it? 'assert' will check if the symbol > is imported and not NULL. Is there side effect if I just applied this > rule as a generic one. > -- F=E1bio Santos