我有一些源代码有许多条件会导致跳过当前列表迭代的其余部分:
for name, row in recent.iteritems():
if name in ignore:
print name + "is on ignore list. Skipping."
continue
if number_of_open_orders_in(name) == max_orders_per_market:
print name + "has max number of open orders. Skipping."
continue
if row[0].ask < 100e-8:
print name + "is a single or double satoshi coin. Skipping."
continue
gain.append(
(
name,
percent_gain(row[0].ask, row[1].ask),
row[1].ask,
row[0].ask,
'https://bittrex.com/Market/Index?MarketName={0}'.format(name),
)
)
如您所见,代码非常规则。跳过的每个原因
row
或name
True
,
答案 0 :(得分:0)
以下是删除了冗余的代码:
for name, row in recent.iteritems():
if name in ignore:
print name + "is on ignore list. Skipping."
elif number_of_open_orders_in(name) == max_orders_per_market:
print name + "has max number of open orders. Skipping."
elif row[0].ask < 100e-8:
print name + "is a single or double satoshi coin. Skipping."
else:
gain.append(
(
name,
percent_gain(row[0].ask, row[1].ask),
row[1].ask,
row[0].ask,
'https://bittrex.com/Market/Index?MarketName={0}'.format(name),
)
)