Why nested scope rules do not apply to inner Class?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Thu Aug 14 06:03:47 CEST 2008

On Wed, 13 Aug 2008 23:40:50 -0400, Calvin Spealman wrote:

> I know every rule has its exceptions. I put "don't nest classes" in with
> other similar rules I will claim, where I think its safest to say "Never
> do this!", because only then will you know that, should you actually do
> it at some point, you've got a reason good enough to break a "rule".

I would put it like this:

"Never nest classes, unless you need to, or to win a bet."

I've never yet needed to nest a class inside a class, but I've used a 
"class factory function", a function that returned classes.


More information about the Python-list mailing list