python3: 'where' keyword
Nick Coghlan
ncoghlan at iinet.net.au
Sun Jan 9 00:54:08 EST 2005
Paul Rubin wrote:
> 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.
Here's another nice one if 'where' is added to compound statements as well:
@dbc(pre, post)
def foo():
pass
where:
def pre():
pass
def post():
pass
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-list
mailing list