Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44796

Re: How to avoid PEP8 'imported but unused'

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jiang.adam@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.085
X-Spam-Evidence '*H*': 0.83; '*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; 'wrote:': 0.18; 'module': 0.19; 'seems': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; '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; '+0100,': 0.31; 'assert': 0.31; 'problem': 0.35; 'received:209.85': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'received:209': 0.37; 'thank': 0.38; 'generic': 0.38; 'sure': 0.39; 'you.': 0.62; 'content-disposition:inline': 0.62; 'received:122': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'side': 0.67; 'safe': 0.72; 'to:charset:iso-8859-1': 0.74; '05,': 0.84; 'fail.': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=bciCJcvLFEmx06lSDlpmx2GuwwVZxwtYAFKnD+f0Hz8=; b=Aw8F5NK45qjUecpxhzexnni1S6uhOw6CK1VVKfghFnIuHF0Cj/wLvteRHb7ap4OBR7 6ABxWYp+EEJAzEaBmtAimVVVebzXM+2q0oWDk/drRIfBDofPWb5A+/P/WHUvwq9aXI/7 zeBCqSE9pvldIhmgLoPmFGTJMPUJcdrwmAEbume6yywYuuZb7o1tARltyT4fPyz1rerz hJha0nJsmGROvv1rKn8Ss/kAyKmxI8c2rt6s4sSCgK9Bx9RschXKGW2OjsvZ9UOgns0x 6CMKo5TjhwyIqEp1B9o2JkgDVvKgb0k3KeOLdmKW+rPAMXsEf7EKBFPwig39nVnUrC9c 1efQ==
X-Received by 10.66.248.163 with SMTP id yn3mr24561864pac.39.1367808483989; Sun, 05 May 2013 19:48:03 -0700 (PDT)
Date Mon, 6 May 2013 11:47:57 +0900
From Adam Jiang <jiang.adam@gmail.com>
To Fábio Santos <fabiosantosart@gmail.com>
Subject Re: How to avoid PEP8 'imported but unused'
References <20130505160054.GA10521@capricorn> <CAA=1kxT6M_wn7Ek+RAN9Zo1KJ7T4sMdDgDd4LC1CqaRJkToNqQ@mail.gmail.com> <20130505164030.GA12637@capricorn> <CAA=1kxRS5P0UZnsUeFwq_W397sj-oB6oX-oOj5Fzy9HDse3=UA@mail.gmail.com>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Disposition inline
Content-Transfer-Encoding 8bit
In-Reply-To <CAA=1kxRS5P0UZnsUeFwq_W397sj-oB6oX-oOj5Fzy9HDse3=UA@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1315.1367808493.3114.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367808493 news.xs4all.nl 15911 [2001:888:2000:d::a6]:52341
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44796

Show key headers only | View raw


Thank you. Problem solved.

/Adam
On Sun, May 05, 2013 at 06:27:44PM +0100, Fábio Santos wrote:
> 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ábio Santos

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to avoid PEP8 'imported but unused' Adam Jiang <jiang.adam@gmail.com> - 2013-05-06 11:47 +0900

csiph-web