连接列表末尾的语法错误无效

时间:2014-08-14 14:44:32

标签: python syntax-error sage

我已经将列表连接在一起,然后在尝试使用%attach(filename)将其加载到SAGE时,我一直收到错误:

File "/projects/f6f895ae-ee58-4e39-9ebc-34b6285d9dec/regs_180k_200k_conca.py", line 5484
SyntaxError: invalid syntax"

这一行是我列表中的最后一行之后的。所以在这种情况下,我的.py文档中没有第5484行。为什么会这样?

这是我列表中的最后两行。它们都被+ \。

恰当地连接起来
[[['199988f1', 1], 160, 161, [[241, 2]]], [['199990a1', 2], 158, 160, [[523, 0], [613, 0]]], [['199990b1', 2], 156, 161, [[13, 1], [283, 0], [557, 3], [673, 0], [827, 0]]], [['199990d1', 1], 156, 158, [[43, 2], [163, 2]]], [['199990e1', 1], 154, 158, [[11, -1], [13, 2], [19, -1], [787, 2]]], [['199990f1', 1], 160, 161, [[317, 2]]], [['199991a1', 1], 152, 157, [[19, -1], [29, -1], [47, -1], [149, -1], [251, -1]]], [['199992a1', 2], 158, 160, [[5, 1], [479, 0]]], [['199992b1', 2], 151, 158, [[5, 1], [59, 0], [71, 3], [89, 0], [97, 0], [127, 3], [491, 0]]], [['199992c1', 2], 153, 157, [[7, 1], [79, 0], [409, 0], [719, 0]]]]+\
[[['199992d1', 1], 155, 155, []], [['199992e1', 1], 159, 159, []], [['199992f1', 1], 157, 160, [[5, 0], [29, 0], [79, -1]]], [['199992g1', 1], 162, 162, []], [['199993a1', 1], 158, 161, [[5, 2], [13, -1], [53, -1]]], [['199994b1', 1], 155, 159, [[7, 2], [11, 0], [283, -1], [449, -1]]], [['199994f1', 1], 158, 161, [[433, -1], [691, -1], [863, -1]]], [['199996a1', 1], 150, 160, [[7, 3], [13, -1], [37, -1], [97, -1], [103, -1], [257, -1], [331, 2], [383, -1], [541, -1], [811, -1]]], [['199998b1', 1], 156, 161, [[5, -1], [17, -1], [73, 2], [211, -1], [227, -1]]], [['199998e1', 1], 158, 161, [[5, -1], [239, -1], [283, -1]]], [['199998g1', 1], 152, 153, [[17, 2]]], [['199998h1', 1], 157, 158, [[283, -1]]], [['199998j1', 2], 153, 156, [[7, 3], [13, 3], [181, 0]]], [['199998k1', 2], 156, 160, [[23, 3], [79, 3], [167, 0], [461, 0]]], [['199998l1', 1], 156, 161, [[5, 2], [13, 2], [71, 2], [211, -1], [233, -1]]]]

这是我用来生成列表的代码。

D = CremonaDatabase()
regall=[]
bigtam = []
i = 0
for x in D.iter(range(190833,200000)):  ##change this range as necessary
    r = x.rank()
    if r > 0:
        if x.cremona_label()[-1] == '1':
            ptn = prod(x.tamagawa_numbers())
            if ptn > 1500:  ##choose your tamagawa product cutoff...i chose 1500
                print '%s, %s: large tamagawa product!!!!!!!!!!!!!!'%(x.cremona_label(), ptn)
                bigtam.append(x.cremona_label())
            else:
                A = [[x.cremona_label(), r]]
                B = []
                gocountall = 0
                gocountvr = 0
                for p in prime_range(5,1000):
                    if x.is_good(p) and x.is_ordinary(p):
                        reg = x.padic_regulator(p,prec=8)  ##try prec = 8 for all conductors between 80k and 200k
                        v = reg.valuation()
                        if v == r:
                            gocountvr = gocountvr + 1
                        if v != r:
                            B = B +  [[p, v]]
                        gocountall = gocountall+1
                 t2 = cputime()
                 regall = regall + [A + [gocountvr] + [gocountall] + [B]]
                 if i%10 == 9:
                      print regall[i-9:i+1]
                      sys.stdout.flush()
                 i = i+1

 print 'regs = ', regall
 sys.stdout.flush()
 print 'TO DO =', bigtam
 sys.stdout.flush()

显然我已经删除了所有大型玉川产品'打印输出以及很好地连接列表。我不认为错误在列表本身内,因为我已经有过几次这种情况并且它指定了错误的位置。所以我已经删除了列表中可能不正确的所有案例。

我还在列表中的其他行中切换了最后一行,每次都得到相同的错误。所以我不认为这是最后一行的问题,因为否则我认为错误也会发生。

我已经为其他范围做了这个,并且他们已经成功地工作了。

1 个答案:

答案 0 :(得分:2)

如果我的评论没有被看到,因为它在上面的列表中是如此之低:“如果你在文件的末尾添加一个],它导入正常。”