python3: 'where' keyword

Paul Rubin http
Sat Jan 8 05:34:08 EST 2005


AdSR <adsr at poczta.onet.pl> writes:
> > Killer app for this keyword:
> > class C(object):
> >   x = property(get, set) where:
> >     def get(self):
> >       return "Silly property"
> >     def set(self, val):
> >       self.x = "Told you it was silly"
> 
> Hey, this is super-elegant!

Heh, even further:

    z = C() where:
       class C(object):
          ...

Lets you make anonymous classes and singleton objects.



More information about the Python-list mailing list