|
From: Michael F. <fuz...@vo...> - 2010-03-10 11:33:15
|
On 09/03/2010 14:33, Tom Vaughan wrote: > I mean how do I make sure a hex string is written to the .ini file, > not the decimal equivalent? When it is set in the ConfigObj how do you know if it is a hex string rather than decimal? If you want to allow decimal values (integer type) to be set, but write them out as hex strings then you will need to 'wrap' the configobj instance in something that converts the integers to hex strings when they are set, and does the reverse when they are fetched. All the best, Michael > > Sent from my iPhone > > On Mar 9, 2010, at 6:23, David Hostetler <neg...@gm... > <mailto:neg...@gm...>> wrote: > >> you mean... how do you print a hex value as a string? >> >> '%#x' % (val) >> >> Omit the '#' if you don't want the leading '0x'. >> >> >> http://docs.python.org/library/string.html#format-specification-mini-language >> >> >> -David >> >> >> On Mon, Mar 8, 2010 at 15:36, Tom Vaughan <to...@so... >> <mailto:to...@so...>> wrote: >> >> Hi, >> >> I know how to convert a hex string to an int. But how would I write >> out the hex string? Thanks. >> >> -Tom >> >> >> class Preferences(ConfigObj): >> >> def conv_hex(value): >> return int(value, 16) >> >> fdict = { >> 'hex': conv_hex, >> } >> >> def __init__(self, prefsname): >> specsname = prefsname + '.spec' >> if os.path.exists(specsname): >> ConfigObj.__init__(self, prefsname, >> configspec=specsname) >> self.validate(Validator(self.fdict)) >> else: >> ConfigObj.__init__(self, prefsname) >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer. |