Use o Vim Retab para resolver o TabError: uso inconsistente de guias e espaços no recuo?
Peça desculpas pela pergunta do novato, mas eu li o manual,esta pergunta, e tentei várias vezes sem resultados que eu esperava.
Então, eu estava usando o vim para editar um arquivo (anexado). Mas, ao executar, recebi o TabError: uso inconsistente de guias e espaços no erro de indentação.
Aqui está o que eu tentei:
Abra o arquivo com o Vim. tipo:retab
e:x
. Execute o arquivo novamente. Ainda recebi a mensagem TabError.Abra o arquivo novamente e digite:retab!
e:x
. Execute o arquivo novamente. Ainda recebi a mensagem TabError.Abra o arquivo novamente e digite:retab! 4
e:x
. Execute o arquivo novamente. Desta vez, funciona, mas não faço ideia do porquê? Além disso, nos arquivos o recuo parece excessivamente longo. (Eu liaqui que o editor possa exibir 8 espaços para uma guia)Minhas perguntas são:
O que:retab
, :retab!
e:retab! 4
significar?
Por que não:retab
trabalhar no meu arquivo?
#!/usr/bin/env python
#Reduce function for computing matrix multiply A*B
#Input arguments:
#variable n should be set to the inner dimension of the matrix product (i.e., the number of columns of A/rows of B)
import sys
import string
import numpy
#number of columns of A/rows of B
n = int(sys.argv[1])
#Create data structures to hold the current row/column values (if needed; your code goes here)
currentkey = None
alist = [] # list for elelents in A
blist = [] # list ,for elements in B
# input comes from STDIN (stream data that goes to the program)
for line in sys.stdin:
#Remove leading and trailing whitespace
line = line.strip()
#Get key/value
key, value = line.split('\t',1)
print(key, value)
#Parse key/value input (your code goes here)
key = (key.split(',', 1)[0], key.split(',',1)[1])
value = (value.split(',', 1)[0], value.split(',',1)[1], value.split(',',1)[2])
#If we are still on the same key...
if key==currentkey:
#Process key/value pair (your code goes here)
# store all values in a lisl
if value[0]=='A':
alist.append([value[1], value[2]])
else:
blist.append([value[1], value[2]])
#Otherwise, if this is a new key...
else:
#If this is a new key and not the first key we've seen, i.e. currentkey!=None
if currentkey:
#compute/output result to STDOUT (your code goes here)
alist = sorted(alist)
blist = sorted(blist)
newlist = [a[1]*b[1] for a,b in zip(alist, blist)]
res = newlist.sum()
print(currentkey, res)
currentkey = key
#Process input for new key (your code goes here)