up with PyGUI!

Peter Hansen peter at engcorp.com
Fri Sep 24 13:08:28 CEST 2004

Greg Ewing wrote:
> For a while now I've been wondering whether Python could
> benefit from an "instance" statement that works similarly
> to a class statement but creates instances instead of
> classes.
> e.g.
>   class MainFrame(FrameDescription):
>     instance b1(ButtonDescription):
>       size = (40, 40)
>       text = "b1"
> Haven't figured out all the details of how it would
> work, though...

I think you can probably force the current implementation to
work this way, with a little work.  You'd need to *slightly*
change the above spelling though, and make sure you were
using one of the standard Python implementations and not,
say, something that didn't follow the language reference:

class MainFrame(FrameDescription):
     b1 = ButtonDescription(
         size = (40, 40),
         text = "b1",

That's pretty close to what you asked for.  You're welcome,
in advance. <wink>

(Actually, I suspect you wanted slightly different behaviour,
but I'm not clear on what.)


More information about the Python-list mailing list