Need help with Python scoping rules

kj no.email at please.post
Wed Aug 26 11:36:35 EDT 2009


In <1bf83a7e-f9eb-46ff-84fe-cf42d9608e71 at j21g2000yqe.googlegroups.com> Carl Banks <pavlovevidence at gmail.com> writes:

>Yeah, it's a little surprising that you can't access class scope from
>a function, but that has nothing to do with encapsulation.

It does: it thwarts encapsulation.  The helper function in my
example is one that clearly rightfully belongs nowhere else than
the class itself, i.e. encapsulated within the class.  It is only
this silly prohibition against recursive functions in a class
statement that forces one to put it outside the class statement.

kynn



More information about the Python-list mailing list