ConfigParser: what read('non-existent-filename') returns in 2.3.x?

Chris Lambacher chris at kateandchris.net
Thu Jul 20 15:30:22 EDT 2006


On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote:
> Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's
> SuperKaramba widget.
> (http://www.kde-look.org/content/show.php?content=32185)
> 
> I was using 2.4.x python docs as reference and
> ConfigParser.read('non-existent-filename') returns [] in 2.4.x
http://docs.python.org/lib/RawConfigParser-objects.html
That agrees with the docs since read returns a list of successfully parsed
filenames.  Note the docs also say this was added in 2.4.
> 
> One user with 2.3.x reported an error stemming from my use of 
> len(cfgObject.read('potentially-non-existent-filename'))
> 
> File "/home/web/Downloads/afoto-1.5b6.skz/localConf.py", line 53, in load
> TypeError: len() of unsized object
> 
> Can anyone tell me what cfgObject.read('potentially-non-existent-filename')
> returns in 2.3.x?
I suspect it never returns anything which means you are getting None instead
of a list, which would give you the exception above.
> 
> My output:
> >>> import ConfigParser
> >>> cfg = ConfigParser.ConfigParser()
> >>> a = cfg.read('adsfasfdasfd')
> >>> a, len(a), type(a)
> ([], 0, <type 'list'>)
> 
> Thx in advance.
> 
> Daniel.
> -- 
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list