Need help with Python scoping rules

Xavier Ho contact at xavierho.com
Tue Aug 25 18:55:41 CEST 2009


I'm not really quite sure what voodoo I did here, but my code seems to work
in Python 3.1.1 in the following way:

class Demo(object):
    def func(self, n):
        return n * 5
    _f = func(None, 5)

d = Demo()
print(d._f)
print(d.func(5))

# OUTPUT
25
25

So, hmm?

Regards,

Ching-Yun "Xavier" Ho, Technical Artist

Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: contact at xavierho.com
Website: http://xavierho.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090826/f80bc269/attachment.html>


More information about the Python-list mailing list