[PyKDE] converting enum types

Phil Thompson phil at riverbankcomputing.co.uk
Fri Jun 9 10:49:53 BST 2006


On Thursday 08 June 2006 10:18 pm, Eron Lloyd wrote:
> On 6/8/06, Patrick Stinson <patrickkidd.lists at gmail.com> wrote:
> > On 6/8/06, Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> > > On Thursday 08 June 2006 2:55 pm, Patrick Stinson wrote:
> > > > It seems like everywhere that there is an enum value returned from a
> > > > function, like QInputEvent.modifiers(), you get a class defined by
> > > > pyqt. What is the idea behind returning an object of this type
> > > > instead of an int,
> > >
> > > Because enums aren't ints, they are distinct types.
> >
> > funny what you forget when you forsake the rest of the world for a
> > life in python...
>
> Indeed. However, let's hope Python gets first class enums of its own
> soon: http://www.python.org/dev/peps/pep-0354/

But you couldn't use what's proposed to wrap C++ enums. At the very least you 
would need to be able to specify the numeric value associated with each 
member and override the default determined by the position of the member in 
the enum ctor.

Phil




More information about the PyQt mailing list