using "private" parameters as static storage?

Chris Mellon arkanes at gmail.com
Fri Nov 14 11:57:19 EST 2008


On Thu, Nov 13, 2008 at 10:25 PM, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
> On Fri, 14 Nov 2008 13:35:02 +1100, Ben Finney wrote:
>
>> Instead, it looks like you're falling foul of one of the classic
>> mistakes in the "How to ask questions the smart way" document: you've
>> got a goal, but you're assuming that you need to use a specific tool to
>> get there. Instead, you're being shown that your assumption is false:
>> there's a better tool available to achieve your goal.
>
> For the sake of the argument I will accept your characterization of Joe's
> question. Even given that, you have still made an error: Joe hasn't been
> shown that his assumption is wrong, he's merely had a bunch of people
> declare, without evidence or even reason, that he is wrong. If anyone has
> given any reason for avoiding the idiom that doesn't boil down to "I
> don't like it!" (I need a smiley for pursed lips), I haven't read it.
>
> I for one do not think he is wrong, and I have given reasons for
> preferring the idiom:
>
> def parrot(public_args, _cache={})  # or similar
>
> for implementing caches and similar internal storage. It's quick, it's
> easy, it's lightweight, and it exposes the cache to those who need it,
> e.g. for testing.
>
> If anyone has a *reason* why this idiom is harmful, please say so.
> Repeating "That's not the way to do it!!! Use an object!!!" is not a
> reason.
>
> Without such a reason, then the decision whether or not to use a functor
> (class with a __call__ method) in Python is a matter of personal taste.
>


Honestly given his attitude I don't think there's any reason to give
him the benefit of the doubt. Python doesn't have static storage - it
uses objects for the same purpose. Since anyone with the credentials
he's mentioned at least 3 times not only knew the history of OO
programming and how it addresses the same problems that people used
static storage to address, but also could have read one friggin python
tutorial and gotten all the answers he needed, I'm pretty much forced
to decide that he's either a troll or lazy.

Especially since in his email he gave no reason why "just use a
fucking object" isn't a good solution to the problem, and he still
hasn't.

This isn't an UberSpecialTypeFactoryInstance answer, if you'll forgive
me using an answer from a future email. There's a simple, obvious,
straightforward solution to the need to maintain state between
function calls.The entire idea of objects in programming was developed
to fill *exactly this need*.

And finally! You will note that in his email he asked for peoples
opinions and suggestions on how they solve this problem. "I'd use an
object" is a totally reasonable answer to the question he asked. Joe
seems to be pissed off that we didn't answer the question he didn't
ask, and we didn't respect articificial constraints that he didn't
fully express, and apparently that we don't all love RealBasic, which
he talks about a lot. So fuck that.



More information about the Python-list mailing list