On Mar 24, 11:08 pm, Tim Leslie <tim.les...@gmail.com> wrote: > On 25 March 2011 13:51, scattered <tooscatte...@gmail.com> wrote: > > > Here is another possibility: you are using Python *interactively* in > > solving cryptograms (as a matter of fact - I was doing exactly this > > yesterday in trying to solve some Playfair ciphers). You have a > > ciphertext that is a stream of letters in the range A...Z. You need to > > consult frequencies of letters, pairs of letters, triples of letters, > > and quadruples of letters that occur. So, you write a script that > > steps through the cipher text, creates a dictionary which records > > frequencies of strings of length <= 4, and, as an added convienence, > > creates bindings of frequencies to these strings. Thus - if you want > > to know how often, say, EFW occurs in the ciphertext you just type EFW > > (rather than freq["EFW"]) > > And what happens when you want to know the frequency of "if", "def", > "for" or any other variable which matches a keyword? > > Tim
>>> IF = 3 >>> if IF > 1: print("No problem") >>> 'No problem' In a *program* such things are silly - for interactive use where you have motivation to have a family of pre-defined bindings available for possible use, it is perfectly ok. If Python *did* have an upper-case keyword (does it? I couldn't think of any), e.g. NULL, then of course you could write your script to check for that, and for those special cases (which are unlikely to occur as substrings of a cipher text) you could make the binding to something like fNULL instead. -- http://mail.python.org/mailman/listinfo/python-list