Hi Denis,

On Fri, Nov 20, 2015 at 05:08:21PM -0000, Denis McMahon wrote:
> On Fri, 20 Nov 2015 16:53:47 +0100, Peter Otten wrote:
> 
> > Ervin Hegedüs wrote:
> 
> >> Python has a good string formatter, eg. I can do this:
> 
 
> Or even:
> 
> >>> s = "{who} likes {what}"
> >>> d = {'who': "Adam", 'what': "ants"}
> >>> keys = [x[1] for x in string.Formatter().parse(s)]
> >>> keys
> ['who', 'what']
> 
> then ...
> 
> for key in keys:
>     if key not in d:
>         raise KeyError("Missing key '{}' in format string '{}'".format
> (key, s))

well, I think I'm very satisfied - I got better and more better
solutions :).


Thanks for all, folks:

a.
 

-- 
I � UTF-8
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to