i have test.txt file, Find strings and subtring from the wordlist
<aardwolf>
<Aargau>
<Aaronic>
<aac>
<akac>
<abaca>
<abactinal>
<abacus>
test.py file
import sys # the sys module
import os
import re
def hasattr(str,list):
expr = re.compile(str)
# yield the elements
return [elem for elem in list if expr.match(elem)]
isword = {}
FH = open(sys.argv[1],'r',encoding="ISO-8859-1")
for strLine in FH.readlines(): isword.setdefault(''.join(sorted(strLine[1:strLine.find('>')].upper())),[]).append(strLine[:-1])
print (isword)
basestring=str()
for ARGV in sys.argv[2:]:
print ("
*** %s
" %ARGV )#print Argv
diffpatletters = re.compile(u'[a-zA-Z]').findall(ARGV.upper())
#print (diffpatletters)
diffpat = '.*' + '(.*)'.join(sorted(diffpatletters)) + '.*'
#print (diffpat)
for KEY in hasattr(diffpat,isword.keys()):
# print (KEY)
SUBKEY = KEY
for X in diffpatletters:
#print (X)
SUBKEY1 = SUBKEY.replace(X,'')
#print (SUBKEY)
if SUBKEY1 in isword:
#print (SUBKEY)
basestring+= "%s -> %s" %(isword[KEY], isword[SUBKEY1])
print (basestring + "
")
Below is to run the file in command line
python test.py test.txt aack aadfl
Expected out is find the matched the string and sub-string of each after second argument.My basestring not printing