On Tue, 29 Jul 2008 21:31:01 +0000, kj wrote:
> In <[EMAIL PROTECTED]> Larry Bates <[EMAIL PROTECTED]> writes:
>
> [snip]
>
> Maybe it's easier to see what I mean with JavaScript:
>
> function foo() {
> if (foo.x === undefined) foo.x = expensive_call();
> return do_stuff_with(foo.x);
> }
def foo():
if not hasattr(foo, 'x'): foo.x = expensive_call()
return do_stuff_with(foo.x)
or, maybe just define foo in two steps:
def foo():
return do_stuff_with(foo.x)
foo.x = expensive_call()
--
http://mail.python.org/mailman/listinfo/python-list