nested classes
Steve Holden
steve at holdenweb.com
Fri Mar 20 14:35:11 EDT 2009
Benjamin Kaplan wrote:
>
>
> On Fri, Mar 20, 2009 at 10:06 AM, Esmail <ebonak at gmail.com
> <mailto:ebonak at gmail.com>> wrote:
>
> Hello all,
>
> I am curious why nested classes don't seem to be used much in Python.
> I see them as a great way to encapsulate related information, which is
> a
> good thing.
>
> In my other post "improve this newbie code/nested functions in
> Python?"
> (I accidentally referred to nested functions rather nested classes -
> it was late)
> I asked something similar in the context of a specific example where I
> think the
> use of nested classes makes sense.
>
> But perhaps not?
>
>
> Nested classes in Python don't add much other than an additional level
> of complexity (and an extra hash lookup). Behavior in python is usually
> grouped into modules, not into classes. The only reason to nest a class
> in Python is if the first class is going to generate the second class on
> the fly.
>
And even then you;d nest it inside a method of the class.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Want to know? Come to PyCon - soon! http://us.pycon.org/
More information about the Python-list
mailing list