With a little side of applesauce...

Friday, April 6, 2007

ConfigObj - list values (single value in list)

Since Python treats strings as lists, I was caught by surprise when a for loop with only a single value, (which used to work correctly, of course), began to set the values to characters, instead of strings... Then I realized that my configuration file had the following value for the list:

myVar = 'mystring'

Since I am using ConfigObj to create the configuration object for cwsAdmin, I visited the ConfigObj documentation:

and realized that I needed to set lists with single values to:

myVar = 'mystring',

Not very intuitive, and prone to cause logic problems, but thanks to the great documentation, it didn't cause too much trouble :)

No comments: