|
From: Michael F. <fuz...@vo...> - 2010-03-17 18:52:33
|
On 17/03/2010 18:50, Jason Baker wrote:
> On Wed, Mar 17, 2010 at 1:35 PM, Michael Foord
> <fuz...@vo... <mailto:fuz...@vo...>> wrote:
>
> How about setdefault?
>
> >>> c = ConfigObj()
> >>> c['bar'] = 'baz'
> >>> c.setdefault('foo', '%(bar)s')
> 'baz'
>
> Michael
>
>
> I'm assuming you mean using setdefault in lieu of my exception
> handling which is a good idea. However, the exception block isn't
> really my primary concern. It just feels a bit like I'm coupling my
> app a bit too closely to Section's inner workings by going that
> route. I was thinking of something more along the lines of a magical
> "get_by_interpolation" function (or something that would make
> implementing such a function easier). But, if such an animal doesn't
> exist, I suppose I'll just have to deal. :-)
Well - as far as I can tell setdefault is exactly a "magical
get_by_interpolation function" - so I guess I'm not understanding you
(setdefault is also a standard dictionary method).
Michael
--
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.
|