up with PyGUI!
Piet van Oostrum
piet at cs.uu.nl
Fri Sep 24 07:37:55 EDT 2004
>>>>> Greg Ewing <greg at cosc.canterbury.ac.nz> (GE) wrote:
GE> For a while now I've been wondering whether Python could
GE> benefit from an "instance" statement that works similarly
GE> to a class statement but creates instances instead of
GE> classes.
GE> e.g.
GE> class MainFrame(FrameDescription):
GE> instance b1(ButtonDescription):
GE> size = (40, 40)
GE> text = "b1"
How would this be different from:
b1 = ButtonDescription():
b1.size = (40, 40)
b1.text = "b1"
or from this:
def instance(klass, **kw):
inst = klass()
for k in kw:
# could add a check for __getattr__ here
inst.__dict__[k] = kw[k]
return inst
b1 = instance(ButtonDescription,
size = (40,40),
text = "b1")
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list
mailing list