osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pylint false positives


On Wed, Aug 22, 2018 at 10:39 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Wed, 22 Aug 2018 03:58:29 +1000, Chris Angelico wrote:
>
>> On Wed, Aug 22, 2018 at 2:38 AM, Marko Rauhamaa <marko at pacujo.net>
>> wrote:
>>> Gregory Ewing <greg.ewing at canterbury.ac.nz>:
>>>
>>>> Marko Rauhamaa wrote:
>>>>> Lexically, there is special access:
>>>>>
>>>>>    class C:
>>>>>        def __init__(self, some, arg):
>>>>>            c = self
>>>>>            class D:
>>>>>                def method(self):
>>>>>                    access(c)
>>>>>                    access(some)
>>>>>                    access(arg)
>>>>
>>>> [...]
>>>>
>>>> you can do that without creating a new class every time you want an
>>>> instance. You just have to be *slightly* more explicit about the link
>>>> between the inner and outer instances.
>>>
>>> By "*slightly* more explicit," do you mean more syntactic clutter?
>>>
>>>
>> No, he actually means "explicit" in the normal English sense. You're
>> trying to use it in the python-ideas sense of "code that I like", and
>> since you don't like it, you want to call it "implicit" instead, but it
>> obviously isn't that, so you call it "syntactic clutter".
>
> That's an incredible insight into Marko's internal mental state you have
> there. And you get that all from the words "syntactic clutter"? I thought
> he just meant that it was cluttered code. How naive was that?
>
> *wink*
>

Hah. I was just picking up on a few specific parts of the conversation:

1) It's possible to create a class with a number of methods, then
instantiate that class, and have all of its methods be closures.
Lexical containment grants implicit access to the variable "c".

2) It's also possible to create the class at a broader scope, then
instantiate that class, passing it a reference to whatever is in "c".

3) Passing an explicit reference is, if I'm understanding Marko's
scoffing correctly, "syntactic clutter".

4) Clutter is, by implication, unnecessary. In simple assignment "x =
1", we don't consider the equals sign to be "clutter".

My point is that passing the reference truly is "explicit" and relying
on lexical containment truly is "implicit", unlike the usual uses of
those words.

Maybe I misjudged Marko's internal mental state. All I have is his
outputs, so it's like trying to deduce Mersenne's internal state from
its outputs - not fundamentally impossible, but not particularly easy
either. But if I have, he is, as always, most welcome to correct me.

ChrisA