Smalltalk and Python
Steve Williams
sandj.williams at gte.net
Fri Dec 15 10:31:06 EST 2000
More information about the Python-list mailing list
Fri Dec 15 10:31:06 EST 2000
- Previous message (by thread): Smalltalk and Python
- Next message (by thread): comp.lang.ruby (Re: Smalltalk and Python)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Andrew Dalke wrote: > Greg Ewing wrote: > >the TADS (Text Adventure Development System) > >lets you declare objects with multiple > >classes, e.g. > > > > bed: Furniture, Surface, Scenery > > ... > ... > >This is really just syntactic sugar, > ... > >To mention something vaguely Python-relevant: > >if Python had a convenient syntax for declaring > >singletons, it could be a pretty good language for > >Interactive Fiction... > > One packet of syntactic sugar, coming up! > > def make_a(*classes): > class make_a: > pass > make_a.__bases__ = tuple(classes) > return make_a() > > class Furniture: > def comfy(self): return 1 > > class Surface: > def genus(self): return 0 # Imagine a spherical cow... > > class Scenery: > def description(self): return "boring" > > >>> bed = make_a(Furniture, Surface, Scenery) > >>> bed > <__main__.make_a instance at 0x120330628> > >>> bed.description() > 'boring' > >>> bed.genus() > 0 > >>> bed.comfy() > 1 > >>> > > Andrew > dalke at acm.org A cow is genus 1
- Previous message (by thread): Smalltalk and Python
- Next message (by thread): comp.lang.ruby (Re: Smalltalk and Python)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list