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


Groups > comp.lang.python > #101503 > unrolled thread

Re: I'm missing something here...

Started byTerry Reedy <tjreedy@udel.edu>
First post2016-01-11 19:36 -0500
Last post2016-01-11 19:36 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: I'm missing something here... Terry Reedy <tjreedy@udel.edu> - 2016-01-11 19:36 -0500

#101503 — Re: I'm missing something here...

FromTerry Reedy <tjreedy@udel.edu>
Date2016-01-11 19:36 -0500
SubjectRe: I'm missing something here...
Message-ID<mailman.31.1452559005.13488.python-list@python.org>
On 1/11/2016 6:26 PM, Skip Montanaro wrote:
> Here's a dumb little bit of code, adapted from a slightly larger script:
>
> #!/usr/bin/env python
>
> "dummy"
>
> import glob
> import os
>
> def compare_prices(*_args):
>      "dummy"
>      return set()
>
> def find_problems(cx1, cx2, cx3, prob_dates):
>      "dummy"
>      for fff in sorted(glob.glob("/path/to/*.nrm")):
>          sym = os.path.splitext(os.path.basename(fff))[0]
>          prob_dates |= compare_prices("E:%s"%sym, cx1, cx2, cx3)
>
> When I run pylint against it, it complains:
>
> junk.py:10: [W0613(unused-argument), find_problems] Unused argument 'prob_dates'
>
> I must be misunderstanding something about the |= operator as applied
> to sets. If I read the docs correctly, s1 |= s2 is equivalent to
> s1.update(s2). A dumb "test" at the prompt suggests that's true:
>
>>>> s1 = set("abc")
>>>> s2 = set("cde")
>>>> s1 | s2
> set(['a', 'c', 'b', 'e', 'd'])
>>>> s1 |= s2
>>>> s1
> set(['a', 'c', 'b', 'e', 'd'])
>>>> s1 = set("abc")
>>>> s1.update(s2)
>>>> s1
> set(['a', 'c', 'b', 'e', 'd'])
>
> If I change the last line of find_problems to call
> prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW)
> complaining that the prob_dates argument of find_problems is unused
> when I use the |= operator?

A bug in pylint. It should treat both cases the same.


-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web