Код: Выделить всё
import pytricia
pyt = pytricia.PyTricia()
pyt['2400:0:840::/43']='l' # bad block 1
pyt['2400:0:860::/44']='k' # bad block 2
pyt['aaaa:0:860::/44']='k' # control block 1
pyt['aaab:0:860::/43']='k' # control block 2
pyt.keys()
Out[143]: ['2400:0:860::/44', '2400:0:840::/43', 'aaaa:0:860::/44', 'aaab:0:860::/43']
len([x for x in pyt if x not in pyt])
Out[144]: 2
пытается получить доступ к pyt['2400:0:840::/43'] или pyt['2400:0:860:: /44'] возвращает ошибку.
Однако:
Код: Выделить всё
pyt = pytricia.PyTricia()
pyt['2400:0:860::/44']='k' # bad block 2
pyt['2400:0:840::/43']='l' # bad block 1
pyt['aaaa:0:860::/44']='k' # control block 1
pyt['aaab:0:860::/43']='k' # control block 2
pyt.keys()
Out[146]: ['2400:0:840::/43', '2400:0:860::/44', 'aaaa:0:860::/44', 'aaab:0:860::/43']
len([x for x in pyt if x not in pyt])
Out[147]: 0
Код: Выделить всё
len([x for x in y if x not in y])Подробнее здесь: https://stackoverflow.com/questions/790 ... hat-happen