cfg = ConfigObj(newfilename) cfg['key'] = 'value' cfg['key2'] = ['value1', 'value2', 'value3'] cfg['section'] = {'key': 'value', 'key2': ['value1', 'value2', 'value3']}            If the main purpose is to support this kind of notational convenience, then I'd be inclined to require all the values used with this API to be concrete strings, lists or dicts. If you're going to make types part of the API, I think it's better to do so with a firm hand rather than being half- hearted and wishy-washy about it. [snip..]    Thanks, that's the solution we settled on. We use ``isinstance`` tests to determine types.

The user can always do something like :

    cfg['section'] = dict(dict_like_object)

Which isn't so horrible.

All the best,

Michael
   -- Greg _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk">

(original) (raw)

Greg Ewing wrote:
Fuzzyman wrote:



cfg = ConfigObj(newfilename)
cfg['key'] = 'value'
cfg['key2'] = ['value1', 'value2', 'value3']
cfg['section'] = {'key': 'value', 'key2': ['value1', 'value2', 'value3']}



If the main purpose is to support this kind of notational
convenience, then I'd be inclined to require all the values
used with this API to be concrete strings, lists or dicts.
If you're going to make types part of the API, I think it's
better to do so with a firm hand rather than being half-
hearted and wishy-washy about it.
[snip..]

Thanks, that's the solution we settled on. We use \`\`isinstance\`\` tests to determine types.

The user can always do something like :

    cfg\['section'\] = dict(dict\_like\_object)

Which isn't so horrible.

All the best,

Michael
  
\--  
Greg  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Python-Dev mailing list  
Python-Dev@python.org  
http://mail.python.org/mailman/listinfo/python-dev  
Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk