Need Help!!!

Phlip phlip_cpp at yahoo.com
Mon May 27 01:31:28 EDT 2002


Amor wrote:

>  for i in range(len(werte)):
>   if werte[i][1] == 0:
>    pass
>   else:
>    q = float(werte[i][1]*100)/anzahl
>    rela = rela + q
>    abso = abso + werte[i][1]
> 
>    print "\t%s     | %8i     |    %-5.2f    | %-5.2f" %(werte[i][0],
> werte[i][1], q, rela)
>  print "    ----------+--------------+--------------+-------"
>  print "      SUMME   | %8i     |        " %(abso)

Firstly, this is totally procedural code. You need to think about objects; 
to start, in this program you just need to think what's a good data bucket 
to use. If a frequency hit was an object, it could look like this:

        class bucket:
                pass
        aBucket = bucket()
        aBucket.myChar = 'A'
        aBucket.myFrequency = 0

That's attrocious style, but at least it's not pseudocode. But, most 
important, you can associate the letter with its frequency. Then as you 
discover redundant operations on that object you can move the operations 
into methods of the object with intent-revealing names.

Your actual question, however, was how to chart this. Research Python 
MegaWidgets and Tk's BLT library. Pmw ships with a Blt wrapper that I use 
all the time at work. 

-- 
  Phlip
            http://www.greencheese.org/HatTrick
  --  "Why have an attention span when you can
       have a staff [of lawyers]?"  -- Ian Sholes  --




More information about the Python-list mailing list