Python generator behaviour

前端 未结 2 1493
广开言路
广开言路 2020-12-12 00:44
import itertools
ws=[]
subs=[]
set_subs=[]
for i in xrange(int(raw_input())):
    S=raw_input()
    l=len(S)
    subs.append(S[i:j+1] for i in xrange(l) for j in xra         


        
2条回答
  •  不思量自难忘°
    2020-12-12 01:09

    Well, this is one of the strange features of generator expression. Have a look at this In your case it is used late binding and that's why you will get two identical results.

提交回复
热议问题