python dictionary from config parser if value and "%(" in value: argument of type 'int' is not iterable -


getting error in random, appear, not:

for in range(1,32):     sezione = "grp"+str(i)     dizionariogrp = dict(config.items(sezione))     print int(dizionariogrp['r']) 

and error

  file "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap     self.run()   file "/home/pi/gigi.py", line 436, in run     self.esegui()   file "/home/pi/gigi.py", line 307, in esegui     l.gruppo(idgruppo)   file "/home/pi/gigi1.py", line 282, in gruppo     dizionariogrp = dict(config.items(sezione))   file "/usr/lib/python2.7/configparser.py", line 655, in items     option in options]   file "/usr/lib/python2.7/configparser.py", line 663, in _interpolate     if value , "%(" in value: typeerror: argument of type 'int' not iterable 

why referring int, if i've converted in string?

somewhere in code you're doing this:

config.set('something', 'something', 0) # or integer 

or optionally you're passing in non-string value in configparser constructor dict.

this subtly against docs say:

if given section exists, set given option specified value; otherwise raise nosectionerror. while possible use rawconfigparser (or configparser raw parameters set true) internal storage of non-string values, full functionality (including interpolation , output files) can achieved using string values.

so whenever call configparser.set, make sure wrap you're setting in str. otherwise throws error when runs through values in _interpolate. (i consider part of behavior bug, it's kept as-is backwards compatibility. or something.)

another thing use safeconfigparser throw typeerror if try set non-string value, know won't happen again.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -