愚かだと感じています。このiniファイルを考えると:
[main]
source1 = ./testing/sdir1
sync1 = ./testing/sydir1
archive1 = ./testing/adir1
source2 = ./testing/sdir2
sync2 = ./testing/sydir2
archive2 = ./testing/adir2
[logging]
log_dir = .
log_file = pixelsync.log
log_level = DEBUG
次のコードがハングします。
import ConfigParser
CONFIG_FILE = 'pixelsync.ini'
def parse_config() :
    """read details from the config file"""
    global CONFIG_FILE
    config = ConfigParser.SafeConfigParser()
    config.read(CONFIG_FILE)
    index = 1
    while True :
        if config.has_option('main', 'source' + str(index)) and \
                    config.has_option('main', 'sync' + str(index)) and \
                    config.has_option('main', 'archive' + str(index)) :
            result = ( config.get('main', 'source' + str(index)),
                       config.get('main', 'sync' + str(index)),
                       config.get('main', 'archive' + str(index)))
            index += 1
        else :
            if index == 1 :
                print "could not setup any trios from the config file. exiting."
                sys.exit(1)
    return result
if __name__ == '__main__' :
    options = parse_config()
'if'句にぶら下がっています。
'if'句を:に置き換えた場合
if config.has_option('main', 'source1' ) and \
                    config.has_option('main', 'sync1' ) and \
                    config.has_option('main', 'archive1' ) :
ハングしません。(3つのセットの任意の数をループする必要があるため、私が望むことをしませんが、それは静かにハングしません。
Python v2.7.3、ubuntu 12.04(Precise)、32ビット。