Exemplo n.º 1
0
    n = list(range(1, 30, 2))
    for e in seq(n, [], '+', False):
        print(e)

    exit()

    from Goulib.table import Table

    max = 100
    t = Table(range(max + 1), titles=['n'])

    def column(n, monadic='-s', dyadic='+-*/^_', permut=False):
        t.addcol(n)
        col = len(t.titles) - 1
        for e in seq(n, monadic, dyadic, permut):
            n = int(e[0])
            # h(e[0],'=',e[1])
            if n <= max:
                e = e[1]
                old = t.get(n, col)
                if old is None or old.complexity() > e.complexity():
                    t.set(n, col, e)

    column(2018, permut=True)  # yeargame
    column(2019, permut=True)  #yeargame
    column(4444)  # four-four
    column(123456789)
    column(999)  # 999 clock

    t.save('friedman.htm')
Exemplo n.º 2
0
        ref = groupe.find('organeRef').text
        pm = groupe.find('vote/positionMajoritaire').text
        votes = ['contre', 'abstention', 'pour']
        default = votes.index(pm) - 1  # against=-1, no vote=0

        # first we consider all members of the group voted as default:
        for actor in organes[ref]:
            line[acteurs[actor]] = default

        # then remove those who didn't vote:
        for votant in groupe.find('vote/decompteNominatif/nonVotants'):
            ref = votant.find('acteurRef').text
            try:
                del line[acteurs[ref]]
            except KeyError:
                pass  # already deleted (in a different group)

        # and modify those who voted differently:
        for i, vote in enumerate(votes):
            for votant in groupe.find('vote/decompteNominatif/%ss' % vote):
                ref = votant.find('acteurRef').text
                try:
                    line[acteurs[ref]] = i - 1
                    print(acteurs[ref], 'voted', vote)
                except KeyError:
                    logging.error("actor ref %s doesn't exist" % ref)

    res.append(line)

res.save('votes.csv', encoding='iso-8859-15')