Steven D'Aprano <st...@remove-this-cybersource.com.au> wrote:

>I find myself having need of a class where the class scope is included in 
>the scope of methods in the class. A simple example from Python 3.1:
>
>x = "outside"
>
>class Magic:
>    x = "inside"
>    def method(self):
>        return x
>
>
>I would like Magic().method() to return "inside" rather than "outside".

Try this instead:
    return self.x



Best regards,

Günther
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to