greg schrieb: > André Thieme wrote: >> (aif (timeConsumingCalculation) >> (use it)) > > I think the answer is that you just wouldn't do > that in Python at all. Having magic variables > spring into existence in your local namespace > as a side effect of calling something is just > not Pythonic. (It is very Perlish, on the other > hand.) > > The closest you might come is using the new > "with" statement like this: > > with aif(timeConsumingCalculation()) as it: > use(it) > > where the object returned by aif(x) has an > __enter__ method that raises an exception which > aborts the whole with statement if x is None, > thus avoiding executing the body. But that's > so horribly convoluted that any sane programmer > would just write it out the straightforward > way to begin with.
Sounds like "Blub" to me: http://www.paulgraham.com/avg.html I will quote some parts of it: "You can see that machine language is very low level. But, at least as a kind of social convention, high-level languages are often all treated as equivalent. They're not. Technically the term "high-level language" doesn't mean anything very definite. There's no dividing line with machine languages on one side and all the high-level languages on the other. Languages fall along a continuum [4] of abstractness, from the most powerful all the way down to machine languages, which themselves vary in power. [...] Programmers get very attached to their favorite languages, and I don't want to hurt anyone's feelings, so to explain this point I'm going to use a hypothetical language called Blub. Blub falls right in the middle of the abstractness continuum. It is not the most powerful language, but it is more powerful than Cobol or machine language. And in fact, our hypothetical Blub programmer wouldn't use either of them. Of course he wouldn't program in machine language. That's what compilers are for. And as for Cobol, he doesn't know how anyone can get anything done with it. It doesn't even have x (Blub feature of your choice). 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. When we switch to the point of view of a programmer using any of the languages higher up the power continuum, however, we find that he in turn looks down upon Blub. How can you get anything done in Blub? It doesn't even have y. By induction, the only programmers in a position to see all the differences in power between the various languages are those who understand the most powerful one. (This is probably what Eric Raymond meant about Lisp making you a better programmer.) You can't trust the opinions of the others, because of the Blub paradox: they're satisfied with whatever language they happen to use, because it dictates the way they think about programs." André -- -- http://mail.python.org/mailman/listinfo/python-list