osdir.com


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

Pylint false positives


On Sun, Aug 19, 2018 at 6:28 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
>>> In a word, steer clear of metaprogramming.
>>
>> [...]
>> (2) if you mean what you say, that means no decorators,
>
> Correct. I don't find decorators all that useful or tasteful.
>
>> no closures,
>
> Closures I consider ordinary programming. Nothing meta there.

So it's okay to have a function that can be created more than once,
then? Because closures usually will be.

>> no introspection ("reflection" in Java terms),
>
> Introspection is suspect in general.

So, no calling help() or using any sort of automated signature display.

>> no source-code generators.
>
> Lisp-style macros (or scheme syntax rules) are rather a clean way to do
> that, but even that mechanism should be used very sparingly and
> tastefully.

I posted something from an active project of mine earlier. Please
explain how to do it better, in your no-metaprogramming world. Show me
how my code would be improved by avoiding code generation.

>> No namedtuples, Enums, or data-classes.
>
> They don't seem all that meta to me, but coincidentally I never found
> uses for them in my Python code.

They all involve metaclasses, which you have forbidden. Ergo you
should not use them. (At least, I think namedtuple uses a metaclass.
Might be wrong there. It certainly uses exec().)

Your acceptance of closures is a perfect proof of how magic stops
looking like magic once you get accustomed to it. How do closures
actually work? Do you have any idea, or do you just accept that stuff
works the way you expect it to?

If you can accept closures because they just DTRT, why not accept a
much simpler and more obvious operation like putting a 'def' statement
in a loop?

ChrisA