Need help with Python scoping rules

Martin P. Hellwig martin.hellwig at dcuktec.org
Wed Aug 26 09:02:04 EDT 2009


kj wrote:
<cut>
> First, one of the goals of OO is encapsulation, not only at the
> level of instances, but also at the level of classes.
Who says?
Anyway, you could be right (I am not capable to judge it) and Python 
should change on this issue but from what I gathered, Pythons OO is 
inspired by the following:
- Don't repeat yourself
- Containing code into logical units makes it easier to understand and 
maintain.

Note the absence of 'OO is defined as X so we are going to do X without 
thinking if X is actually the best way to do it'

> Your comment suggests that Python does not fully support 
> class-level encapsulation.
Probably right too, but being intrigued, why is that necessary, and 
given an example is that the best way to do it?

> Second, my example shows that Python puts some peculiar restrictions
> on recursion.  Recursion!  One of the central concepts in the theory
> of functions!  
<cut>
It is also one of the best ways to shoot yourself in the foot, but I ask 
you again, is the reason why you encountered this 'limitation' actually 
the best way to solve your problem?

Please forgive my incompetence if this reply sounds harsh and patronizing.

-- 
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'



More information about the Python-list mailing list