nesting class definitions?

Gerrit Holl gerrit.holl at pobox.com
Fri Jan 28 07:40:10 EST 2000


Neel Krishnaswami wrote on 949014837:
> Gerrit Holl <gerrit.holl at pobox.com> wrote:
> > Hello,
> > 
> > I do see the point in nesting function definitions, namely as an alternative
> > on places where one could use lambda. But what's the point in nesting
> > class definitions? I know it's possible, but I've never seen it used.
> 
> I have used it, though for several reasons it's definitely not a
> standard idiom.

[why not use them]

[why use them]

> def class_factory(*mixins):
>     class Anonymous:
>         # some various routines
>     Anonymous.__bases__ = tuple(mixins)
>     return Anonymous
> 
> so that I could call class_factory() to create the appropriate class
> at runtime.

Ah, but what I meant was:

class Jan:
    class Piet:
        ...
    class Henk:
        ...

Is there any point in using this feature?

regards,
Gerrit.

-- 
Please correct any bad English you encounter in my email message!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----




More information about the Python-list mailing list