Re: [Pyme-help] contants -> constant names? for info
Status: Beta
Brought to you by:
belyi
From: Bernhard R. <ber...@in...> - 2008-08-17 21:17:04
|
Igor, On Sunday 17 August 2008 06:51, Igor Belyi wrote: > That's an interesting idea, but I can't think of a python friendly way > to implement it. > > Constants are basically 'integers' which could have conflicting values > from different components. So, whatever > mechanism is chosen to convert from an integer to a string should be > component specific. yes, it should be component specific. > Another approach would be to make constants into 'objects' and then > convert them to integers when they > are passed to gpgme and have __str__() method which prints their name > instead of their value but I think > it's overkill for just an easier 'verbose' capability. > > Let me know what implementation exactly you have in mind. I believe just a reverse dictionary should be created when creating the constants. The problem is that the original names aim to be unique values in C, and the way it is done now, the strings are not unique anymore in a __dict__ or dir(constants.validity). constants.validity.table(uid.validity) might just give me the string. Best, Bernhard -- Managing Director - Owner: www.intevation.net (Free Software Company) Germany Coordinator: fsfeurope.org. Coordinator: www.Kolab-Konsortium.com. Intevation GmbH, Osnabrück, DE; Amtsgericht Osnabrück, HRB 18998 Geschäftsführer Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner |