Steven Bethard <[EMAIL PROTECTED]> wrote: ... > > Your reasoning makes sense... lambda enables you to create a function as > > part of an expression, just like other types can be part of an > > expression. However, by that same reasoning, maybe classes aren't > > special enough either to warrant a special case. Where's the keyword to > > create an anonymous class? :-) > > Well, no keyword, but you can use the type function: > > py> d = dict(c=type('C', (object,), dict(spam=42)), > ... d=type('D', (dict,), dict(badger=True))) > py> d['c'].spam > 42 > py> d['c']() > <__main__.C object at 0x063F2DD0>
Well then, just call new.function to similarly create functions as part of an expression, hm? Passing the bytecode in as a string isn't incredibly legible, OK, but, we've seen worse...;-) Alex -- http://mail.python.org/mailman/listinfo/python-list