Another try at Python's selfishness

n.estner at gmx.de n.estner at gmx.de
Fri Feb 3 06:35:25 EST 2006


Yes, that's what I had in mind when I said it could be made
recursion-safe. It's still not thread-safe, but I think that could be
done too, using thread-local-variables instead of globals.

> class TestB:
>     @memberFunction
>     def do(x):
>         z = __  # lambda's shouldn't directly reference '__'
>         x.do(lambda : z)

Yes, that's what I meant when I said it wasn't lambda-safe. That means
a completely legal and (in my code) common expression can behave
totally unexpected. Would be a no-go for me.

But I think it gets worse:

class TestA:
    @memberFunction
    def do():
        yield 1
        yield 2
        yield __


class TestB:
    @memberFunction
    def bar():
        for x in TestA().do():
            print x

TestB().bar()

Doesn't behave as expected, and the only way I can see to fix it would
be to declare a local function inside TestA's "do" function...




More information about the Python-list mailing list