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


Groups > comp.lang.python > #108390

Re: pylint woes

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Subject Re: pylint woes
Date Sun, 8 May 2016 17:39:44 -0400
Lines 122
Message-ID <mailman.531.1462743587.32212.python-list@python.org> (permalink)
References <ngl677$68p$1@dont-email.me> <CAPTjJmr7A+UH7Wye05_T5WV0kG=DQUrOF2Mc8-uGQ26HKAoCMg@mail.gmail.com> <mailman.457.1462640479.32212.python-list@python.org> <ngm3qs$73r$1@dont-email.me> <572f24bc$0$1618$c3e8da3$5496439d@news.astraweb.com> <ngoajd$kp6$1@dont-email.me> <CAPM-O+xwp2rP6BLSS+YExGo7Hua_x06bEec-s6R76FdP3NJL5g@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de oB16eJYUcR7Y2DCY+fIcHwofAk2xU/LY3XvUpgMSmb6g==
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.03; '[],': 0.07; 'raises': 0.07; 'cc:addr:python-list': 0.09; 'addr': 0.09; 'fails.': 0.09; 'oh,': 0.09; 'way:': 0.09; 'url:blog': 0.10; 'sections': 0.13; 'times,': 0.13; '*i*': 0.16; '2016': 0.16; 'advice,': 0.16; 'atomic.': 0.16; 'dfs': 0.16; 'iterating': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'exists': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'names.': 0.22; 'parse': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'skip:t 40': 0.27; 'message-id:@mail.gmail.com': 0.27; 'document.': 0.27; "i'm": 0.30; 'url:mailman': 0.30; 'skip:[ 10': 0.31; '"the': 0.32; 'addresses': 0.32; 'skip:t 50': 0.32; 'url:python': 0.33; "d'aprano": 0.33; 'point,': 0.33; 'steven': 0.33; "i'll": 0.33; 'url:listinfo': 0.34; 'that,': 0.34; 'list': 0.34; 'advice': 0.35; 'received:google.com': 0.35; 'skip:c 30': 0.35; 'lists.': 0.35; 'question,': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'thought': 0.37; 'starting': 0.37; 'things': 0.38; 'doing': 0.38; 'received:209': 0.38; 'names': 0.38; 'mean': 0.38; 'why': 0.39; 'data': 0.39; 'sure': 0.39; 'whatever': 0.39; 'received:209.85.214': 0.39; 'url:mail': 0.40; 'street,': 0.60; 'address': 0.61; 'here.': 0.62; 'different': 0.63; 'city': 0.65; 'website:': 0.65; 'state,': 0.66; 'url:info': 0.71; 'succeeds': 0.84; 'to:none': 0.91; 'ask,': 0.91; 'joel': 0.91; 'rd,': 0.91; 'scraping': 0.91; 'states,': 0.93
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; bh=vouprW8pyM91UwDlNtK0UQxpjhSAQQYEwrtC7VWlpn8=; b=z0PbIC20WwzsBqGM7PHwHSMfz5bcVvCp9J2TV75FkBthigkAy61Q49iLkrvhe6aK6z nya83aWeHsh2HLpm31fXnpta0FZalqdmUmenzZej7H4JsMp4An5uuu2zDQyUEvKOPBMs RpfQ6UpTosnyieRMgCwSMywyaOi+kfNG5tzHEqSz5PsD3JylzRoagQtI1pOlIq1uCEwX i7U0YkTzKRldUCIBKM5EhUe6cBp3oyet1xHj+in73nDq+qOG3vs9unaBpfByN0P9hLUB IW1dyJ3ViHpHegMCAu5fMEObyMYVp4IVonMqohbTe7iO4wEh+FMv4DlX2Cdw51BMjRSg 6ySA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=vouprW8pyM91UwDlNtK0UQxpjhSAQQYEwrtC7VWlpn8=; b=lBUkP71VRFKSiwzZLJCVjXfJpN7mkxXwuLkojwA31vbC5eJQuH8EzilCH8qZ6FVFNf kpK3KTiDL9BUmKNxwe2H6AStViKpnEiLjsTaulMB72XJJ+w/4aVd5l6Wbb1Gojibzf6y bmmEANy4Hr8po6gJYujhkoxA8o8YKubB7MJDPEnxz3aqtYsJQTpwH5CzGPQZJXugXgU3 Y6LDC1cBrQaEJXUukkjDFmTB7ude3xW0VsLN5ZSmf43YDnGMChT0VaK0YHLhSIpE5TLq 87npa12Fu3FwXQVG3YXL8bd1Lp426zsmPGu+/4QZ8Q/iSy9v/HZpZ9R2PXW6nYnfCUOp xERA==
X-Gm-Message-State AOPr4FVAL3EYS7IVeVQ2tdsMk30Gp0TDihcJMjci45znTc2fCnGv3KOlIbRxmQ4t7msRysa7cnCFtDabDJ2A8g==
X-Received by 10.60.13.132 with SMTP id h4mr11829696oec.70.1462743584502; Sun, 08 May 2016 14:39:44 -0700 (PDT)
In-Reply-To <ngoajd$kp6$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <CAPM-O+xwp2rP6BLSS+YExGo7Hua_x06bEec-s6R76FdP3NJL5g@mail.gmail.com>
X-Mailman-Original-References <ngl677$68p$1@dont-email.me> <CAPTjJmr7A+UH7Wye05_T5WV0kG=DQUrOF2Mc8-uGQ26HKAoCMg@mail.gmail.com> <mailman.457.1462640479.32212.python-list@python.org> <ngm3qs$73r$1@dont-email.me> <572f24bc$0$1618$c3e8da3$5496439d@news.astraweb.com> <ngoajd$kp6$1@dont-email.me>
Xref csiph.com comp.lang.python:108390

Show key headers only | View raw


On Sun, May 8, 2016 at 5:24 PM, DFS <nospam@dfs.com> wrote:
> On 5/8/2016 7:36 AM, Steven D'Aprano wrote:
>>
>> On Sun, 8 May 2016 11:16 am, DFS wrote:
>>
>>> address data is scraped from a website:
>>>
>>> names = tree.xpath()
>>> addr  = tree.xpath()
>>
>>
>> Why are you scraping the data twice?
>
>
>
> Because it exists in 2 different sections of the document.
>
> names     = tree.xpath('//span[@class="header_text3"]/text()')
> addresses = tree.xpath('//span[@class="text3"]/text()')
>
>
> I thought you were a "master who knew her tools", and I was the apprentice?
>
> So why did "the master" think xpath() was magic?
>
>
>
>
>
>
>> names = addr = tree.xpath()
>>
>> or if you prefer the old-fashioned:
>>
>> names = tree.xpath()
>> addr = names
>>
>> but that raises the question, how can you describe the same set of data as
>> both "names" and "addr[esses]" and have them both be accurate?
>>
>>
>>> I want to store the data atomically,
>>
>>
>> I'm not really sure what you mean by "atomically" here. I know what *I*
>> mean
>> by "atomically", which is to describe an operation which either succeeds
>> entirely or fails.
>
>
> That's atomicity.
>
>
>
>> But I don't know what you mean by it.
>
> http://www.databasedesign-resource.com/atomic-database-values.html
>
>
>
>>> so I parse street, city, state, and
>>> zip into their own lists.
>>
>>
>> None of which is atomic.
>
>
> All of which are atomic.
>
>
>
>>> "1250 Peachtree Rd, Atlanta, GA 30303
>>>
>>> street = [s.split(',')[0] for s in addr]
>>> city   = [c.split(',')[1].strip() for c in addr]
>>> state  = [s[-8:][:2] for s in addr]
>>> zipcd  = [z[-5:] for z in addr]
>>
>>
>> At this point, instead of iterating over the same list four times, doing
>> the
>> same thing over and over again, you should do things the old-fashioned
>> way:
>>
>> streets, cities, states, zipcodes = [], [], [], []
>> for word in addr:
>>     items = word.split(',')
>>     streets.append(items[0])
>>     cities.append(items[1].strip())
>>     states.append(word[-8:-2])
>>     zipcodes.append(word[-5:])
>
>
>
>
> That's a good one.
>
> Chris Angelico mentioned something like that, too, and I already put it
> place.
>
>
>
>> Oh, and use better names. "street" is a single street, not a list of
>> streets, note plural.
>
>
>
> I'll use whatever names I like.
>
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Starting to look like trolling.  Lots of good advice here.  If you
ask, and don't like the advice, don't use it.
-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays

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


Thread

pylint woes DFS <nospam@dfs.com> - 2016-05-07 12:51 -0400
  Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 03:01 +1000
    Re: pylint woes DFS <nospam@dfs.com> - 2016-05-07 21:16 -0400
      Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 11:36 +1000
        Re: pylint woes DFS <nospam@dfs.com> - 2016-05-07 22:15 -0400
          Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 12:50 +1000
            Re: pylint woes DFS <nospam@dfs.com> - 2016-05-10 18:36 -0400
              Re: pylint woes MRAB <python@mrabarnett.plus.com> - 2016-05-11 02:02 +0100
      Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-07 19:14 -0700
        Re: pylint woes DFS <nospam@dfs.com> - 2016-05-07 23:04 -0400
          Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-07 20:46 -0700
            Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 10:26 -0400
          Re: pylint woes Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-08 08:50 +0300
            Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 10:25 -0400
              Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-09 00:36 +1000
                Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 11:06 -0400
                Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-08 08:15 -0700
                Re: pylint woes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-05-09 13:17 +1200
                Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-09 12:18 +1000
                Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 22:58 -0400
                Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-09 01:15 +1000
                Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:06 -0400
              Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-08 08:11 -0700
              Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-09 01:51 +1000
                Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:04 -0400
                Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-09 13:09 +1000
      Re: pylint woes MRAB <python@mrabarnett.plus.com> - 2016-05-08 03:21 +0100
      Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-08 21:36 +1000
        Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:24 -0400
          Re: pylint woes Joel Goldstick <joel.goldstick@gmail.com> - 2016-05-08 17:39 -0400
          Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-09 13:46 +1000
  Re: pylint woes Michael Selik <michael.selik@gmail.com> - 2016-05-07 18:42 +0000
  Re: pylint woes Peter Pearson <pkpearson@nowhere.invalid> - 2016-05-07 18:43 +0000
    Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:05 -0400
  Re: pylint woes Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-07 11:52 -0700
    Re: pylint woes DFS <nospam@dfs.com> - 2016-05-07 23:38 -0400
      Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 13:56 +1000
      Re: pylint woes Peter Otten <__peter__@web.de> - 2016-05-08 16:19 +0200
  Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-07 12:21 -0700
  Re: pylint woes Stephen Hansen <me@ixokai.io> - 2016-05-07 12:23 -0700
  Re: pylint woes Terry Reedy <tjreedy@udel.edu> - 2016-05-07 15:40 -0400
    Re: pylint woes DFS <nospam@dfs.com> - 2016-05-07 23:28 -0400
      Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 13:51 +1000
        Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 00:40 -0400
          Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 14:55 +1000
      Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-07 20:55 -0700
      Re: pylint woes Ian Kelly <ian.g.kelly@gmail.com> - 2016-05-07 23:09 -0600
      Re: pylint woes Peter Otten <__peter__@web.de> - 2016-05-08 16:12 +0200
  Re: pylint woes Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-07 12:43 -0700
  Re: pylint woes Ray Cote <rgacote@appropriatesolutions.com> - 2016-05-07 15:52 -0400
  Re: pylint woes Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-07 13:20 -0700
  Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 07:56 +1000
  Re: pylint woes Terry Reedy <tjreedy@udel.edu> - 2016-05-07 21:44 -0400
  Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-08 13:25 +1000
    Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 00:10 -0400
      Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 14:21 +1000
      Re: pylint woes "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2016-05-08 08:50 -0400
      Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-08 23:01 +1000
        Re: pylint woes Larry Hudson <orgnut@yahoo.com> - 2016-05-08 13:45 -0700
          Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-09 08:07 +1000
            Re: pylint woes Larry Hudson <orgnut@yahoo.com> - 2016-05-08 18:28 -0700
        Re: pylint woes Dan Sommers <dan@tombstonezero.net> - 2016-05-08 20:49 +0000
          Re: pylint woes Chris Angelico <rosuav@gmail.com> - 2016-05-09 08:10 +1000
      Re: pylint woes Steven D'Aprano <steve@pearwood.info> - 2016-05-09 03:25 +1000
        Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:16 -0400
          Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-08 14:38 -0700
            Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 17:46 -0400
              Re: pylint woes Stephen Hansen <me+python@ixokai.io> - 2016-05-08 15:05 -0700
                Re: pylint woes DFS <nospam@dfs.com> - 2016-05-08 18:24 -0400

csiph-web