woooee 814 Nearly a Posting Maven

xvkbd runs on Linux and SendKeys has a source package, probably a python extension, so it should work but I haven't tried it.

woooee 814 Nearly a Posting Maven

There is also xvkbd, but it is a console program and so is accessed via:
os.system('xvkbd -test "string to type" ')
http://homepage3.nifty.com/tsato/xvkbd/

woooee 814 Nearly a Posting Maven

i have highlighted part of the code,were it stops.

What does 'stop' mean? What is the error message? The message will tell you what the problem is. Also, you want to consider breaking the program into functions so you don't have one large mess that you can't figure out. A good intro book is the first link that follows. Functions are section 4.6 and handling errors is covered in section 8
http://www.network-theory.co.uk/docs/pytut/ There are more Python books here
http://linkmingle.com/list/List-of-Free-Online-Python-Books-freebooksandarticles

woooee 814 Nearly a Posting Maven

It should be
pool = 30
The [] turn pool into a list and you want an integer variable.

woooee 814 Nearly a Posting Maven

First, here is the way I __think__ your code looks when properly formatted.

#!/usr/bin/python
##import string          ##    string is deprecated
import re
import random
import sys
import time
import fileinput

tn = time.time()
t = str(tn)
ss = "5571"
lv = open("/usr/local/https/data/session1.txt","r")
lvr = lv.readlines()
l_lvr = len(lvr)
#print lvr
l_list = []
for i in range(l_lvr):

     test = re.split('\|', lvr[i])
     l_list.append(test)
     #print l_list
     for u,s,t,sp in l_list:
          if s == ss:
               so_list = [u, s, t, sp]
               u = string.join(so_list)
               #print f
               s_list = u,s,t,sp
               e = so_list[2]
               print e
               to = s_list[2]
               #print st_to
               too = float(to)
               f = tn - too
               if f < 3600:
                    so_list[2] = str(tn)
                    sn_list = so_list
                    print sn_listg =string.join(sn_list)
               print g
for line in open('/usr/local/https/data/session1.txt', "r"):
     line = line.replace(u, g)
     sys.stdout.write(line)
sys.exit()

##---  don't know where the else goes
else:
#return 1
print "kK"
sys.exit()
print "no"

As you can see, it takes way too much time to try and fiqure out the code. so you are not getting any responses. Just click the "#" icon above the posting box and put your program between the code statements. The basic format of the program would be

fp = open(file_name, "r")
fp_out = open(file_name+".new", "w")
for rec in fp:
     u,g = function_to_calculate_u_g_for this record()
     ##    split the input rec into name, id, time, etc
     ##    write to ".new" file
     fp_out.write("%s %s %s %s\n" % (name, id, u, g))
fp_out.close()

The data is now in a new file. You now move the …

woooee 814 Nearly a Posting Maven

MySQLdb is just a python wrapper around MySQL. So you also have to have MySQL installed. I don't know about Mac's but you probably also have to have the MySQL daemon running. A Google for "mac mysqldb" will probably turn up thousands of hits from people who have already done this. Also, they both should be in Apple's software repository, which would install for you.

woooee 814 Nearly a Posting Maven

printB is not part of the class unless you define as being a class member, like so

def printB(self):
         print "B"

You then call it with
self.printB()
See this page from "How To Think Like A Computer Scientist" http://www.greenteapress.com/thinkpython/html/book018.html

woooee 814 Nearly a Posting Maven

Which tutorial are you using? I have never seen it used with
import MySQLdb
but it may be that I just don't know about that alternative way.

woooee 814 Nearly a Posting Maven

I get errors on the following line because there is no file on the first pass through the program. So you should first get the program to run properly if there is no file found, without manually changing the code, .

a = Petty(p.load(f))

and the following lines yield a name not defined error. Perhaps you should debug this code first, and then ask for help. (Buggy code says you don't understand this so there is no reason to add to it).

self.accountname = accountname
        self.department = department
        self.responseperson = responseperson
        self.phone = phone
        self.email = email
woooee 814 Nearly a Posting Maven

To open it, as opposed to viewing in Acrobat, you will likely have to open as a binary file
print open(file_path, "rb")
There is pypdf, and probably others, for working with a pdf file in python. You would also probably use PIL (Python Imaging Library) if there are embedded images in the pdf file.

You may have to use a double backslash, as I'm on Linux I don't know, so just use .join if there are problems.
file_path = os.path.join("c:", "Broucher.pdf")
And are you sure it is not "Brochure"? HTH.

woooee 814 Nearly a Posting Maven

Good point. Time to download 3.0 and do a search of comp.lang.python. It has undoubtedly been discussed. For now, I will have to form the habit of using
print("hello world")
as that works in both 2.5 and 3.0.

woooee 814 Nearly a Posting Maven

Just an educated guess, but you would have os.system call the pdf browser with the file name (but this is on Linux).
os.system('Acrobat c:\resume.pdf')

woooee 814 Nearly a Posting Maven

First, if this is just a one-time thing for you, you can use Links to download and save the page as text only. http://www.jikos.cz/~mikulas/links/download/binaries/ Also, I assume you know about BeautifulSoup and that is more than you want. To answer your questions
1. Stops after 10 iterations (as the saying goes, this is too coincidental to be a coincidence)

def run(self,URL,limit=10):
                 ## and 
		while i<limit:

2. Single letters are in the dictionary. Difficult to tell but some print statements will add some light. I'm thinking that you want to use j, since it is each word from the split(), but the print should clarify that.

def handle_data(self,data):
     l = []
     m = []
     n = []
     for s in data:
          print "s in data", s
          l = s.split()
## fixed indentation problem
          for j in l:
               print "     j in l", j
               m.append(j)
## wouldn't h be the same as j, so m=l
          print "\n'l' =", l
          print "'m' =", m
          for h in m:
               print "          h in m", h
               h = h.strip(' ,.?!-')
               h = h.lower()
               n.append(h)
##   if "s" is one record from data, then indentation problem (fixed)
          n.sort()
          for i in n:
               if i.isalpha():
                    if i in self.word_dictionary:
                         self.word_dictionary[i]=self.word_dictionary[i]+1
                    else:
                           self.word_dictionary[i]=1
##
##--------This might easier to understand ------------------------
##           but I'm not sure what your data looks like
     for rec in data:
          word_list= rec.split()
          for word in word_list:
               word = word.strip(' ,.?!-')
               word = word.lower()
               if word in self.word_dictionary:
                    self.word_dictionary[word] += …
woooee 814 Nearly a Posting Maven

You could also get the python version
print sys.version_info
and then use the appropriate "print input_var" or "print(input_var)" depending on whether version is > 2.5.

woooee 814 Nearly a Posting Maven

This part prints the usage blurb and exits if you don't include usage options on the command line. "h", "t", and "a" are the usage options and are directly below the quoted code.

def main():
  try:
    opts, args = getopt.gnu_getopt(sys.argv[1:], "h:t:a")
  except getopt.GetoptError:
    usage()
    return
woooee 814 Nearly a Posting Maven

it now makes the last word the longest?

Add some print statements and you should be able to see what is going on.

for word in splicedsent:
    print "\ncomparing word %s, length=%d, longest=%s" % \
             (word, len(word), longestLength)
    if len(word) > longestLength:
        longestword=word
        print "length > longest is true"
woooee 814 Nearly a Posting Maven

return' outside function line 35.
What does that mean?

You have a "return" statement outside the confines of a function. Which is correct. There is no function definition in your program, and you can't do a function return from no function.

woooee 814 Nearly a Posting Maven

As has already been hinted, you are probably expected to use 2 lists. The first contains letters and the second contains the number for the corresponding letter. You could also use a list of lists, with each sub-list containing the letter and number, but that is probably more than you can wrap your head around at this point. Do whatever makes sense to you. There are only 26 letters in the English alphabet, so the list is very small, which means that any method with take about the same amount of time. Code something, and append it to the thread for additional help.

woooee 814 Nearly a Posting Maven

You don't have to use a tuple to store the guesses. A list is normally used, but you can also use a string thusly (this is not meant to be a complete solution)

guess_word = "alfalfa"
correct_guess = ""
wrong_guess = ""
previous_guesses = ""
                                                                              
## generate a list to test with instead of input
tries = [ "a", "b", "e", "a", "o" ]
for guess in tries:
   if guess in previous_guesses:
      print guess, "has already been guessed"
   elif guess in guess_word:
      print guess, "is correct"
      correct_guess += guess
   else:
      print guess, "is NOT correct"
      wrong_guess += guess
   previous_guesses += guess

Also, I prefer to use a function, and return at a breakpoint. Perhaps that will be easier to get your head around.

def guess_word(random_word):

   guess_count = 0
   correct_guess = ""
   wrong_guess = ""
   previous = ""

   while guess_count < 6: 
      guess_count+=1
      guess=raw_input("\nguess one letter ")

      if guess in previous:
         print guess, "has already been guessed"
         guess_count -= 1         ## don't charge for duplicate guesses
      elif guess in random_word:
         print guess, "is correct"
         correct_guess += guess
      else:
         print guess, "is NOT correct"
         wrong_guess += guess
      previous += guess
      ##---   while testing, check that this works correctly
      print correct_guess
      print wrong_guess

   print len(correct_guess), "correct guesses and", len(wrong_guess), "incorrect"        

   ##---  This is the return part                               
   while 1:
      print  "You have to guess the word now"
      guess_word=raw_input("What say you (hit Enter to quit) ")
      guess_word = guess_word.strip()
      if len(guess_word) == 0:   ##  Enter key only
         return
      elif guess_word.lower() == random_word:
         print …
Murtan commented: I like your solution, I was just hoping to encourage the OP to do more +1
woooee 814 Nearly a Posting Maven

Your last 2 lines would be modified thusly

primeNum = int(raw_input("Enter number here:"))
prime_list = listfactors(primeNum)  ## your function returns a list
for prime in prime_list:
    print "prime =", prime

Also, a second for using modulo or divmod. Your function compares integers and floats and you will be comparing numbers like int=1, and float=0.99999 because of the nature of using floats which will always test false. Hopefully you are only testing integers for "primeness" and so should work with integers only. Finally, it is bad form to use "i", "l", or "o" as single letter variables, as they look too much like numbers.

woooee 814 Nearly a Posting Maven

Assuming that the server belongs to your ISP, you want to first ask them if Python is supported. It usually is, and they probably have some examples of the types of things they allow. Unlike using IDLE, the program file would be run from the command line or another program and how you do that would depend in part on which operating system you are using. This is the web programming page on the Python Wiki (and may be more than you want right now) http://wiki.python.org/moin/WebProgramming

vegaseat commented: thanks for the info +11
woooee 814 Nearly a Posting Maven

I've flagged this as a bad post. Since this is the first time, hopefully it was done correctly. This was the message:

This post is from someone who posted a link to their homework assignment, with no attempt to code anything themselves, and then asked for the answer. Further, they berate someone for not reading the homework assignment completely. Any one who is too lazy to cut and paste the question into the forum should not criticize someone else. We don't want to encourage the attitude of, "I'll sit here on the veranda in my rocking chair while you go fetch the homework from the web for me, and then code the answer while I sit here rocking away". Obviously, this violates the "only help those who shown some effort" and also violates the "keep it pleasant" guidline.

woooee 814 Nearly a Posting Maven

If it is easier to get your head around, you can use a dictionary of lists, with the dictionary key as the row number, each containing x columns. You could also take this one step further and use a dictionary of dictionaries with row and column number as keys.

def populate_array(rows, columns):
   array_dic = {}
   for row in range(1, rows+1):     ## starts with one, not zero
      array_dic[row] = []
      for col in range(0, columns):
         array_dic[row].append('None')     ## initialize to 'None'
   return array_dic
   
if __name__ == "__main__":
   rows = 10
   columns = 5
   ret_dic = populate_array(rows, columns)
   for key in ret_dic.keys():
      print key, ret_dic[key]
      
   ##---  change some value
   row = 3
   col = 1
   ret_dic[row][col] = 'Changed'
   print "\n"
   for key in ret_dic.keys():
      print key, ret_dic[key]
woooee 814 Nearly a Posting Maven

Note the last line

_mysql_exceptions.ProgrammingError: (1146, "Table 'router.table_name' doesn't exist")

It is looking for "table_name" not the contents of the variable. So you want to insert the actual name which can be done in a number of ways along the general line of the following. This is just your statement with one extra "%s" added for the table_name. It is not tested, and I don't use MySQL, but the principle should work.

SQL_statement = 'INSERT INTO %s(device_name,event_date,event_time,event_action,event_protocol,event_src_ip,event_src_port,event_dst_ip,event_dst_port,event_num_pckts) VALUES ("%s","%s","%s","%s","%s","%s","%s","%s","%s","%s")' %
(table_name,vice_name,event_date,event_time,event_action,event_protocol,event_src_ip,event_src_port,event_dst_ip,event_dst_port,event_num_pckts) 

print SQL_statement  ## examine for correctness
q.execute(SQL_statement)
woooee 814 Nearly a Posting Maven

See the last post here for the general idea http://www.daniweb.com/forums/thread158680.html You want to use some variable in a while loop that you can set to false if (1) the correct word is guessed, (2) the maximum number of guesses is reached, (3) any other exit criteria. You can also use a function and return on any of the above.

woooee 814 Nearly a Posting Maven

I've added some print statements so you can see what is going on. First, the file name used for the zip file output is printed to make sure you are using the correct file name (if you submit "C:\\Test\\ZipDir" then the output file will be under "C:\\Test\\" and will be named "ZipDir.zip"), and second, you want to know if any files were actually found for the path arg submitted to the function, and third, if you are recombining the path and file name correctly by testing for "isfile" ("dirs" is not used in your program which may or may not be O.K.). Finally, you want zipp to point to a file in a different directory otherwise you will also be zipping the file that is output of the zip operation and that's not good.

def zip_fh(path):
   print "1) output file name is %s.zip" % (path)
   zipp = zipfile.ZipFile('%s.zip' % (path), 'w')
   for root, dirs, files in os.walk(path, topdown=True):
      print "2)", len(files). "files found"
      for fname in files:
         fh = os.path.join(root, fname)
         if os.path.isfile(fh):
            zipp.write(fh, os.path.basename(fh), zipfile.ZIP_DEFLATED)
         else:
            print fh, "3) is not a legitimate path and file name"
   zipp.close()
woooee 814 Nearly a Posting Maven

Ran the program computer outputs 10 random words.

That's all the program was supposed to do. Now you will have to tell the user the number of letters, use a loop to ask for guesses, and compare to letters in the word with the appropriate correct/incorrect response.

woooee 814 Nearly a Posting Maven

Instead of the seek method, you could also use a dictionary to assign a number to each word, and then pick a random integer and print the word associated with that integer. IMHO it is preferable to use numbers whenever possible as that is the native language of the computer.

from random import randint
   
def read_file():
   words = {}
   ctr = 0
   dic_path="/usr/local/DictionaryE.txt"
   fileptr =open (dic_path ,"r")
   for rec in fileptr:
      words[ctr] = rec.strip()
      ctr += 1
   fileptr.close()
   return words


if __name__ =="__main__":
 
   word_dictionary = read_file()
   limit = len(word_dictionary) - 1

   n =10
   print "%d randomly generated words from a list of %d\n" % \
         (n, limit)
 
   for i in xrange (n ):
      offset = randint (0, limit )
      word = word_dictionary[offset]
      print offset, word
   print
woooee 814 Nearly a Posting Maven

For the first part, use a class and declare variables that are global within the class. Classes are included in Python for a reason. You will want to use a class for programs that go beyond one simple function. For example:

class TestClass:
   def __init__(self, input_a):
      self.A=input_a     ##   global
      self.B=0     ##   global
      self.change_1()
      print self.B, self.A
      self.change_2()
      print self.B, self.A

      self.test_list=[]
      self.add_to_list(random.randrange(0,10))
      self.add_to_list(random.randrange(0,10))
      print "test_list has %d elements" % (len(self.test_list))


   def add_to_list(self, num):
      for j in xrange(0, num):
         self.test_list.append("")

   def change_1(self):
      self.A += " Change 1"
      self.B += 1


   def change_2(self):
      self.A += " & Change 2"
      self.B += 2

if __name__ == "__main__":
   empty_string=""
   TC1=TestClass(empty_string)
   empty_string="not empty ??"
   TC2=TestClass(empty_string)
woooee 814 Nearly a Posting Maven
still_testing = True
while still_testing:
   bin = raw_input("\nEnter a binary number: ")
   if len(bin):
      still_testing = False
   for num in bin:
       if int(num) not in [0, 1]:
           print "Invalid input for", num
           still_testing = True
woooee 814 Nearly a Posting Maven

I use a class 99% of the time. Once the program gets beyond the simple function level, it organizes the code IMHO. Also, a class doesn't have any of the global variable problems.

woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven
binary = int(raw_input("Enter a binary number:"))
for i in range(binary):
    print "for loop is testing", i, "in range", binary
    if (binary != 0 or binary != 1):
        print binary, "not equal to 0 or 1"
        binary = int(raw_input("Enter a binary number:"))
    else:
       print binary, "equal to 0 or 1"
woooee 814 Nearly a Posting Maven

No, but from what I know you need to disclose your code.

Where did that come from? If you include open source code in your app, and you transmit it to third parties outside (of your business, home, etc), you have to include source __to_the_open_source_parts_of_the_code__ . Redhat, which is a company that "sells" open source software, they actually sell installation, service etc., for years used their own closed-source installation app to install open-source software. They did not publish the source code and were not required to because it was their own closed-source app. The way I understand Qt's license is "if you make money using Qt, then you owe Trolltech something in return", but again that is just my understanding.

woooee 814 Nearly a Posting Maven

I would suggest the following print statements to clarify things.

print "length of self.__fields =", fieldlength
for counter1 in range(fieldlength):
          if self.__fields[counter1] == field:
            print "counter1 == field"
            for counter2 in range(rowlength):
              #print self.__rows[counter2][counter1]
              if self.__rows[counter2][counter1] == value:
                return1 = counter2
                matchcount = matchcount + 1
                print "The Match count is INSIDE THE LOOP: " + str(matchcount)
##              counter2 = counter2 + 1         Has no effect
          else:
             print "counter1 & field NOT equal"
##          counter1 = counter1 + 1   ## this statement does nothing

Note that the last statement is commented because it has no effect. Run the following code to see for yourself. This is because the statement "for ctr in range(0, 10)" generates a list [0, 1, 2...9] and iterates over this list so you increment the current value when incrementing the counter but don't change the list so there is no effect on the for() loop.

for ctr in range(0, 10):
   print "loop's counter =", ctr
   ctr += 5
   print "     ", ctr, "= incremented but doesn't have any effect"
woooee 814 Nearly a Posting Maven

But now I want to be able to save it in file, preferably in form like this:

number;name

It's a simple combination so a common text file will work just fine. There is also the advantage of being able to verify what you have written to the file via any text processor. Note that dictionaries hash keys so they are not necessarily in key order.

def read_from_file():
   after_d = {}
   fp = open("test.txt", "r")
   for rec in fp:
      rec=rec.strip()
      key, name = rec.split(";")
      after_d[int(key)]=name        ## convert key back to an integer
   fp.close()
   return after_d


def save_to_file(save_d):
   print "before saving to file", save_d
   fp = open("test.txt", "w")
   for key in save_d.keys():
      fp.write("%d;%s\n" % (key, save_d[key]))  ## writes everything as a string
   fp.close()
   

before_d = {}
before_d[1]="Name 1"
before_d[2]="Name 2"
before_d[3]="Name 3"
before_d[10]="Name 10"
before_d[20]="Name 20"

save_to_file(before_d)
after = read_from_file()
print "read from file       ", after
woooee 814 Nearly a Posting Maven

Installing setuptools...
Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c8-py2.6.egg <===== BAD URL - try it yourself
Traceback (most recent call last):
File "<string>", line 267, in <module>
File "<string>", line 198, in main
File "<string>", line 146, in download_setuptools
File "/usr/local/lib/python2.6/urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
File "/usr/local/lib/python2.6/urllib2.py", line 389, in open
response = meth(req, response)
File "/usr/local/lib/python2.6/urllib2.py", line 502, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python2.6/urllib2.py", line 427, in error
return self._call_chain(*args)
File "/usr/local/lib/python2.6/urllib2.py", line 361, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.6/urllib2.py", line 510, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
*****************************

If appears that the URL to download
setuptools is no longer valid. This page says that you don't have to use setuptools but can just move the files yourself. I haven't used it so I don't know. http://wiki.pylonshq.com/display/pylonscookbook/Using+a+Virtualenv+Sandbox You could also install setuptools yourself.

woooee 814 Nearly a Posting Maven

You're making it too difficult. Store the previous record in memory.

prev_line = ""
for line in infile:
     linesplit = line.split(",")
     line = line[:-1]

     if line startswith("Line"):
           write stuff
     if line startswith("$GPGGA"):
          calculate and write stuff
     if line startswith("EOL")
          outfile.write("%s\n" % (prev_line))   <==========
     ##  copying = last thing in this loop
     prev_line = line                              <==========
woooee 814 Nearly a Posting Maven

I cannot use pytesser for this

Why not? The odds of finding someone who would start from scratch instead of using existing code is pretty small. Look for something that exists (is proven) and can use whatever image format you have, as the code would have to process a given image format first, and convert to characters second. I'm sure there are more articles like this one that list existing options http://groundstate.ca/ocr so convert the image, which can usually be done via the command line/os.system(), and then search for the characters in the converted file.

woooee 814 Nearly a Posting Maven

Also, you open the file and read the entire file for each ID entered. This is time consuming (in computer time) and so you should consider reading the file once and placing the records in a dictionary, indexed on ID, and using the dictionary to look up the info as it is entered.

woooee 814 Nearly a Posting Maven

You don't initialize Total2 to zero for each run through the outer loop

#sum each 5 fields over the raw:
    for step in range (6, N, 5):
        Total2=0     <--------------------------
        for i in range (step-5, step, 1):
            Total2 += float(fields2[i])
            # do something
                     
        print i, step, Total2
woooee 814 Nearly a Posting Maven

“In religion and politics people’s beliefs and convictions are in almost every case gotten at second-hand, and without examination, from authorities who have not themselves examined the questions at issue but have taken them at second-hand from other non-examiners, whose opinions about them were not worth a brass farthing.” —- Mark Twain (once again)

woooee 814 Nearly a Posting Maven

You would use a dictionary as a container. The key would be the time stamp. Each key would have a list that would be initialized to something like ["*", "*", "*"], assuming there aren't any "*"s in the file. The first file would replace the first "*", or zero element, for the time stamp, the second file the second, and ditto for the third. After all files have been read and the dictionary updated (via a function--you don't have to write a separate routine for each file), you print/write it to a file. In the combined file, you will use everything that is not equal to "*".

woooee 814 Nearly a Posting Maven

You could also split, subtract 3 (for the end fields) from the length of the sub-string list, which would yield the number of elements to join for the city name. Providing each record is exactly the same.
Or, you can start from the other end
yr=substrs[-1]
q3_2008=substrs[-2]
q3_2007=substrs[-3]

woooee 814 Nearly a Posting Maven

The easiest way to understand it is to break each part down and give it a separate variable name.

"""      
dictFoldersNew = {"A":{"XYZ": [["Name1", "UID1"], ["Name2", "UID2"]],
"PLM": [["Number1", "UUID1"], ["Number2", "UID2"]],
"RST": [["ID1", "UUID1"], ["ID2", "UID2"]]},
"B": [["IDB1", "UID1"], ["IDB2", "UID2"]],
"C": [["IDC1", "UID1"], ["IDC2", "UID2"]],
"D": [["IDD1", "UID1"], ["IDD2", "UID2"]]}
"""      

top_level = {}
top_level["A"] = {}
top_level["B"] = []
top_level["C"] = []

##---  populate "A"
level_2_dic = top_level["A"]
level_2_dic["XYZ"] = []
level_2_dic["PLM"] = []

this_list = level_2_dic["XYZ"]
this_list.append(["Name1", "UIX1"])
this_list.append(["Name2", "UIY2"])

this_list = level_2_dic["PLM"]
this_list.append(["Number1", "UUID1"])
this_list.append(["Number2", "UUID2"])

##---  populate "B"
this_list = top_level["B"]
this_list.append(["IDB1", "UID1"])
this_list.append(["IDB2", "UID2"])

##---  populate "C"
this_list = top_level["C"]
this_list.append(["IDC1", "UIE1"])
this_list.append(["IDC2", "UIE2"])

##--- print all data
for key in top_level:
   print key
   if type(top_level[key]) is dict:
      level_2 = top_level[key]
      for sub_key in level_2:
         print "     dictionary", sub_key
         this_list = level_2[sub_key]
         for each_list in this_list:
            print "          list", sub_list
   elif type(top_level[key]) is list:
      print "     list"
      this_list in top_level[key]:
      for each_list in this_list:
         print "          list", sub_list
   print
   
##  you can also do this
print top_level["A"]["XYZ"][0]   ## first list in "XYZ" in "A"

You want to get away from the word processing thought pattern, where you have lines in documents in folders. None of that really exists. With programming you have one continuous stream of bytes, either in memory or on disk. Then you have pointers to the memory/disk location. So, you want to access the pointer to "A" and access the bytes at that location which gives the pointer to …

woooee 814 Nearly a Posting Maven

The python.org website has a beginners guide that includes links to tutorials and introductory books. http://wiki.python.org/moin/BeginnersGuide

woooee 814 Nearly a Posting Maven

Enumerate is one way to do it.

for ctr, word in enumerate(words):
      word = clearup(word)
      if word not in dictionary:
         print "%s : line %d" % (word, ctr)
woooee 814 Nearly a Posting Maven

You might also want to consider a dictionary, with the guess as the key, and the Yes/No response as the value. It's simplier to understand in this case IMHO. Also, in the following code snippet, you don't use "i" for anything. That is you perform the same exact compare for however many letters are in codeword. I think you want to use
if codewordguess in codeword:
or something similiar

for i in range(len(codeword)):
            print "comparing", i, codeword, codewordguess
            if codeword == codewordguess:
                correct = correct + 1
##          if codeword != codewordguess:     ##  redundant if statement
            else:
                incorrect = incorrect + 1
woooee 814 Nearly a Posting Maven

I use JEdit and BlueFish. JEdit is the only editor that I know of that allows you to configure the cursor. If you are going back and forth to the screen, it is difficult to pick up that single flashing line, so I like the transparent box cursor, in a color bright enough to see. Bluefish has projects, which can be helpful depending. In general, you want something that has tabs (you will always have more than one file open), syntax highlighting, and some sort of indicator to tell/let you know if you have closed the parens blocks. I think every editor has an auto indent feature, so that's not an issue. Auto completion is more trouble than it is worth in my opinion, but for those who are keyboard-challenged, it might help. For most of us, it just gets in the way. BTW, Kate is in the Ibex repos and is a decent editor as well. If you can't find it, it may be in one of the partner repos, but it comes up in Synaptic for me.

woooee 814 Nearly a Posting Maven

Or you could append a copy of the list

import random
 
# faces of a dice
dice = [1, 2, 3, 4, 5, 6]
 
rolls = []
for k in range(3):
    random.shuffle(dice)
    #test
    print dice
    rolls.append(dice[:])
 
# test
print rolls
#
"""  My test
[5, 2, 4, 6, 1, 3]
[2, 4, 1, 6, 5, 3]
[5, 6, 4, 3, 1, 2]
[[5, 2, 4, 6, 1, 3], [2, 4, 1, 6, 5, 3], [5, 6, 4, 3, 1, 2]]
"""