I haven'tdon't have time to fully review all of your code (at least for now), but here's some recommendations:
If I'm not mistaken,
xrange()starts at0if no first argument is given (this is the case withrange()in Python 3). So unless you need to start at another initial value, leave out the first argument and just callxrange(end<upper bound>). The same goes forrandom.randrange(), by the way.Some of your variable names are bad (non-descriptive)not descriptive. EspeciallyIn particular
dictionary1anddictionary2, among othersand (all_chars2). As I didn't go through all of your code, I have no clue why you're using two seperate dictionaries, but you'd probably be able to get rid of the duplicatessecond one by rewriting your program slightly. [dictionary1is equal todictionary2]Make use of the
stringmodule:>>> import string >>> string.ascii_lowercase 'abcdefghijklmnopqrstuvwxyz' >>> string.ascii_uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' >>> string.digits '0123456789' >>> string.punctuation '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'You really should limit typecastingThere's no need to cast the filename to a minimum, because it confuses others who look at your codestring:
dicname = 'dict/base.txt' # Anyone remotely familiar with Python understands that dicname is str.a `str` with open(str(dicname), "wb") as fp: # Confusing, because this makes it seem as though itit's gotnot typecasteda beforehand.`str`