Friday, March 9, 2012

Recursively formatting a dictionary of strings

I have a use-case where I'm using a dictionary as a basis for generating a configuration file, and many of the values in the file share pieces, such as URL bases or credentials. I will also be generating configuration files for several different instances from the same dictionary.
I wanted a simple way to define replaceable parts of the dictionary. I made a couple of Google searches, didn't find anything on the first page, so I wrote this:
I hope it's useful to someone else, or that I find it next time I have this use-case. :)

3 comments:

  1. Thanks. It can be useful.

    Btw, you can replace type({}) with types.DictionaryType and type("") with types.StringType.

    ReplyDelete
  2. Thanks Alexander. I knew there was a simpler way to reference those basic types, but I always forget it at code time. :)

    ReplyDelete
  3. Heya¡­my very first comment on your site. ,I have been reading your blog for a while and thought I would completely pop in

    Appear fervent about it. I’m developing a fresh blog plus I’m struggling to make it look good, as well as offer the best

    quality content. I have learned much at your web site and also I anticipate alot more articles and will be coming back

    soon. Thanks you.


    Journal Editing and Formatting Service

    ReplyDelete