Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there {Raw,Safe}ConfigParser in Python 3?

Am surprised there's 3 different forms: RawConfigParser, SafeConfigParser and ConfigParser (docs). I read the differences but why isn't everyone using SafeConfigParser, since it seems, well, safe? I can understand that in the case for Python 2 that the other two were kept for backward compatibility.

UPDATE: In Python 3.2, SafeConfigParser has been renamed to ConfigParser, and the old ConfigParser has been removed (source: NEWS for Python 3.2).

like image 749
tshepang Avatar asked May 17 '10 11:05

tshepang


People also ask

Is Configparser built in Python?

configparser comes from Python 3 and as such it works well with Unicode. The library is generally cleaned up in terms of internal data storage and reading/writing files.

What does Configparser do in Python?

The configparser module from Python's standard library defines functionality for reading and writing configuration files as used by Microsoft Windows OS. Such files usually have . INI extension.


1 Answers

In short, use configparser.SafeConfigParser.

To quote the docs, SafeConfigParser "implements a more-sane variant of the magical interpolation feature. This implementation is more predictable as well. New applications should prefer this version if they don’t need to be compatible with older versions of Python."

It seems that the old ConfigParser still exists in Python 3 for backwards compatibility: not everything was made backward-incompatible!

like image 55
blokeley Avatar answered Oct 15 '22 23:10

blokeley