Can I define nested classes in Python?

Alex Martelli aleax at aleax.it
Sat Apr 12 15:04:04 EDT 2003


Rene Pijlman wrote:

> Terry Reedy:
>>sdieselil:
>>> Can I define nested classes in Python
>>
>>Try it and see what happens.
> 
> This may have been how Thomas Edison constructed the light bulb,
> but this is not the Right Way to learn a programming language.

Different people learn best in different ways.  There's no One
Right Way.  Reading manuals that are identified as being "for
Language Lawyers", such as the one you mention:

> A better approach is to read the manual.
> http://www.python.org/doc/current/ref/nested-scopes.html

may perhaps be a Right Way for you, or me, but I think that "try
and see" will probably work for a vaster proportion of users.

Though most users will probably be best served by another approach
yet, one between those two extremes -- some experimentation, some
reasoning and explanation, then back to some more experimentation...


Alex





More information about the Python-list mailing list