Smalltalk and Python

Andrew Dalke dalke at
Fri Dec 15 05:49:23 CET 2000

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:
  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()
>>> bed.genus()
>>> bed.comfy()

                    dalke at

More information about the Python-list mailing list