newb question about @property

Steve D'Aprano steve+python at pearwood.info
Wed Oct 4 01:32:59 EDT 2017


On Wed, 4 Oct 2017 02:00 am, bartc wrote:

> Does all this advanced stuff (which I don't understand and which doesn't
> look very appealing either; hopefully I will never come across such
> code) still count as programming?

I could not have hoped to see a more perfect example of the Blub effect in
action if I had invented it myself.


    As long as our hypothetical Blub programmer is looking 
    down the power continuum, he knows he's looking down.
    Languages less powerful than Blub are obviously less
    powerful, because they're missing some feature he's used
    to. But when our hypothetical Blub programmer looks in
    the other direction, up the power continuum, he doesn't
    realize he's looking up. What he sees are merely weird
    languages. He probably considers them about equivalent
    in power to Blub, but with all this other hairy stuff
    thrown in as well. Blub is good enough for him, because
    he thinks in Blub.


http://www.paulgraham.com/avg.html


> It seems to me the equivalent of an advanced driving course teaching you
> how to customise your car rather than involving any actual driving.

You don't think that adding a cache for an expensive function is programming?

If you had ten expensive functions, and you wanted to add a cache to each of
them, would you write out ten separate caches (probably copying and pasting
the code each time)?

Or would you write a function that builds a cache and adds it to the expensive
function *once*, then call it ten times, once for each function being
wrapped?

My examples didn't include a full-blown cache, just the beginnings of one, but
the principle still stands. Program smart, not hard: don't do things by hand
if you can write a function to do them.

That you think that this is not programming is an indictment off your
programming skills. These sorts of functional programming techniques go back
to the 1950s, Lisp is literally the second oldest high-level language ever
(only Fortran is older). You may or may not have been a hotshot in your
little corner of the programming world, but there's an entire world out
there.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list