else文でre.compileとfn()が何をしているかについてのいくつかの洞察が必要ですか?re.compileとは何ですか?また、else文のfn()は何ですか? fnは最初に2つの引数で定義されています
def extract_bc(lines): #function name
xy_series = re.compile(r"XY1|XY2|XY3") #what is this doing?
card_index = _card_index(lines)
bc = []
for line in lines:
card, value = _parse_card(line)
fn = transform.get(card, False)
if fn is False:
bc.append(line)
elif fn is None:
continue
elif isinstance(fn, str):
bc.append(line.replace(card, fn))
else:
bc.append(fn(card, value, card_index)) #what is this doing?
'xy_series'は2回目で言及されていないので、regexコンパイラを使用して文字列を正規表現に変換するのに時間と労力を無駄にしています。 –
'fn = transform.get(card、False)'はこのスコープであなたの 'fn'を定義しています。 'transform.get()'が返すものは、ここにある証拠にない内容に依存します。 –
私はfn =が何をしているのかを見ていますが、else文ではfn(card、value、card_index)何をしていますか? – millerlyte79