woooee 814 Nearly a Posting Maven

freq / k this will return plain ZERO

If it is less than one then it is being rounded to zero because divide defaults to integers in Python 2.X, so convert to float
float(freq) / k
and see if that makes a difference. If not, post some test data as well.

woooee 814 Nearly a Posting Maven

FWIW, a more generic solution using a list to keep track of the maximum's value and the number of times it occurs.

def find_the_max(blist):
    ## a list containing the value and the number of times it appears
    max_group = [blist[0], 0]
    this_group = [blist[0], 0]
    for el in blist:
        if el == this_group[0] :
            this_group[1] += 1
        else:
            ## test for a new max
            if this_group[1] > max_group[1]:
                max_group = this_group[:]
            this_group = [el, 1]

    ## allow for the final group to be the longest
    if this_group[1] > max_group[1]:
        max_group = this_group[:]
    print max_group


blist = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]
find_the_max(blist)
clist = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]
find_the_max(clist)
woooee 814 Nearly a Posting Maven

This program should use a class. For the foo_sell() function as it is, pass 'cash' and 'dealers' to it and return them as well, avoiding globals.

I have never had a problem with declaring globals like this

You have now and hopefully have learned that lesson.

woooee 814 Nearly a Posting Maven

'student' has not been declared so who knows what this does.

data = student.sport
        k = len(student.fname)

What happens when the key is not found?

for i in data:
            freq[i] = freq.get(i, 0) + 1

Your code is poor at best. Add some print statements, print the dictionary after each add, or do whatever to test it as you go along to make sure that you have something to calculate.

woooee 814 Nearly a Posting Maven

If somebody would be able to help me create a simple script that would say "Hello" every time the left mouse button is clicked, I have the rest of what I would like to do figured out

There is also pyMouse http://code.google.com/p/pymouse/

There is this example for xlib
http://ltool.svn.sourceforge.net/viewvc/ltool/trunk/LtMacroAPI.py?view=markup

I have only used curses for the very few times I have wanted to do something like this http://www.ibm.com/developerworks/linux/library/l-python6.html or termios

""" capture and print keyboard input
"""
import termios, sys, os
TERMIOS = termios
def getkey():
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~TERMIOS.ICANON & ~TERMIOS.ECHO
        new[6][TERMIOS.VMIN] = 1
        new[6][TERMIOS.VTIME] = 0
        termios.tcsetattr(fd, TERMIOS.TCSANOW, new)
        c = None
        try:
                c = os.read(fd, 1)
        finally:
                termios.tcsetattr(fd, TERMIOS.TCSAFLUSH, old)
        return c

if __name__ == '__main__':
        print "type something...'q' to quit"
        s = ''
        while 1:
                c = getkey()
                if c == 'q':
                        break
                print "captured key", c, ord(c)
                s = s + c

        print s
woooee 814 Nearly a Posting Maven

what would be the requirements be to make Xlib work on a Windows machine?

The system calls would be different on Windows so the code would differ too much to make it practical. There probably is something similar but something for MS Windows with a Python wrapper as well is another matter

woooee 814 Nearly a Posting Maven

It should be something with ButtonReleaseMask. Try this code and Google for ButtonReleaseMask if it doesn't work.

import Xlib
import Xlib.display

display = Xlib.display.Display(':0')
root = display.screen().root
root.change_attributes(event_mask=
Xlib.X.ButtonPressMask | Xlib.X.ButtonReleaseMask)

while True:
    event = root.display.next_event()
    print "Hello button press"
woooee 814 Nearly a Posting Maven

effbot's tutorial turns up as the first hit for a Google of "tkinter scrollbars". Since we don't know what you want to attach it to, effbot would be the place to start. This is effbot's code for a canvas widget as an example.

from Tkinter import *

root = Tk()
frame = Frame(root, bd=2, relief=SUNKEN)

frame.grid_rowconfigure(0, weight=1)
frame.grid_columnconfigure(0, weight=1)

xscrollbar = Scrollbar(frame, orient=HORIZONTAL)
xscrollbar.grid(row=1, column=0, sticky=E+W)

yscrollbar = Scrollbar(frame)
yscrollbar.grid(row=0, column=1, sticky=N+S)

canvas = Canvas(frame, bd=0,
                xscrollcommand=xscrollbar.set,
                yscrollcommand=yscrollbar.set)

canvas.grid(row=0, column=0, sticky=N+S+E+W)

xscrollbar.config(command=canvas.xview)
yscrollbar.config(command=canvas.yview)

frame.pack()

root.mainloop()
woooee 814 Nearly a Posting Maven

This is a decent tutorial on functions http://www.penzilla.net/tutorials/python/functions/

woooee 814 Nearly a Posting Maven

It would generally be something in this ballpark

file_pointer = open("Handylist.csv", "r")

name_in = raw_input("Enter the name")
for rec in file_pointer:
    substrs = rec.split()
    name = substrs[x]   ## don't know where this is
    if name == name_in:
        print("%s Found" % (name))
woooee 814 Nearly a Posting Maven

raw_input will never be a type int or float. I would use one function.

def get_input(literal):
    while True:
        str_in = raw_input("Whats the %s? " % (literal))
        try:
            float_in = float(str_in)
            return float_in
        except:
            print "Invalid input...try again"

interest = get_input("interest")
deposit = get_input("deposit")
deduction = get_input("deduction")
print interest, deposit, deduction
woooee 814 Nearly a Posting Maven

Just read it, line by line, as a normal file, unless it is not a text file, in which case you would have to read and convert to text. See 2.4.5 here http://www.rexx.com/~dkuhlman/python_101/python_101.html#SECTION004450000000000000000

woooee 814 Nearly a Posting Maven

For those that don't already know:
September 19th is talk like a pirate day,
The 2nd-8th of November, 2009 was sausage week in the UK,
Jan 1-7, 2010 is silent record week,
Jan, 2010 is also California dried plum digestive month,
the first Monday in January is always "Thank God It's Monday" day,
Jan 3rd is "Remember you die" day,
and more importantly, January is
National Clean Up Your Computer Month

woooee 814 Nearly a Posting Maven

I had a simple solution using a list of lists to associate the letter with the original position.

def find_letter(letter, list_in, stars_list):
   for ch_list in list_in:
      ##print("     comparing %s and %s" % (letter, ch_list[0]))
      if letter == ch_list[0]:
         print("     found %s" % (ch))

         ## replace '*' with letter
         el = ch_list[1]     ## original position of this letter
         stars_list[el] = letter

         ## remove letter's list from the list of lists
         list_in.remove(ch_list)
         return list_in, stars_list

   ## letter not found so return original lists
   return list_in, stars_list


original_word = "Dictionary"
original_word = original_word.lower()

## convert word into list
word_list = [(ch, x) for x, ch in enumerate(original_word)]
print word_list

## list of '*' to be printed
stars_list = []
for ch in word_list:
   stars_list.append("*")

## simulate some guesses entered
guesses = ["A ", " b  ", "c", "I", "t", "i"]
for ch in guesses:
   ch = ch.strip().lower()
   word_list, stars_list = find_letter(ch, word_list, stars_list)
   print " ".join(stars_list)
   print word_list
woooee 814 Nearly a Posting Maven

You have to enter "d:\" to make it equal to "d:\\" since backslash is the escape character. Why not make it simple and test for "D:" only. I've added some print statements to clarify.

#!/usr/bin/python3
import os
import sys

whileloop = True

while(whileloop):
    initial_drive = "C:\\"
    inputline = input(initial_drive)
    print("inputline = %s" % (inputline))
    if inputline == "exit":
        whileloop = False
    elif inputline == "about":
        print("no input")
    elif inputline == "":
        print("write a command and press enter.")
    elif inputline in ["d:\\", "d:"]:  ## enter either "d:\" or "d:"
        initial_drive = "D:\\"
        print("initial_drive is now %s" % (initial_drive))
    else:
        print("bad command")
woooee 814 Nearly a Posting Maven

It's pretty straight forward, and since I'm sick and not doing much today...

test_data = [ "c The random seed used to shuffle this instance was seed=1755086696",
              "p cnf 1200 4919",
              "-35 491 -1180 0",
              "479 1074 -949 0",
              "609 1177 -67 0" ]

formula = []
for rec in test_data:
   rec=rec.strip()
   junk_list = []

   ## record has to start with a number or a minus sign
   if (rec[0].isdigit()) or (rec[0].startswith("-")):
      substrs = rec.split()
      for num in substrs:
         try:
            num_int = int(num)
            if num_int < 0:
               junk_list.append( (abs(num_int), 0) )
            elif num_int > 0:         ## eliminate zero
               junk_list.append( (num_int, 1) )
         except:
            print "error converting", rec

      formula.append(junk_list)
print formula
jmark13 commented: Fast and accurate code. Thanks! +1
woooee 814 Nearly a Posting Maven

This is why we have SQL. I have a work in progress that generates simple SQLite code for throw away applications. This is the code it generated for your application. The test_data() function adds some records with the data you provided. You should be able to figure how to add all of the data by looking at the function. Also, the function list_all_recs() prints the file sorted on total cost, so that is an example of how to extract data in the order you want. If you can not adapt this to your application, post back, and note that there are couple of of functions that are not used but are there as a general reminder since this is just boiler plate.

import os
import sqlite3 as sqlite


##======================================================================
class DummyClass:
   def __init__( self ) :
      self.SQL_filename = './test_apt_dbf'
      self.open_files()

   ##   END  __init__()

   ##----------------------------------------------------------------------
   def add_rec( self ) :
      val_tuple=(self.a_city, self.a_price, self.a_size, self.a_rent, self.a_tel, self.a_address, self.a_total_cost, self.a_cost_size)
      self.cur.execute('INSERT INTO test_apt_dbf values (?,?,?,?,?,?,?,?)', val_tuple)
      self.con.commit()

   ##   END  AddRec()

   ##----------------------------------------------------------------------
   def copy_to_struct( self, rec ) :
      self.a_city = rec[0]
      self.a_price = rec[1]
      self.a_size = rec[2]
      self.a_rent = rec[3]
      self.a_tel = rec[4]
      self.a_address = rec[5]
      self.a_total_cost = rec[6]
      self.a_cost_size = rec[7]

   ##   END  copy_to_struct()

   ##----------------------------------------------------------------------
   def list_all_recs( self ) :
      self.cur.execute("select * from test_apt_dbf order by a_total_cost")
      recs_list = self.cur.fetchall()
      for rec in recs_list:
         print rec

   ##   END  list_all_recs

   ##----------------------------------------------------------------------
   def lookup_first_field( self ) :
      self.cur.execute("select * from test_apt_dbf where a_city==:dic_lookup", {"dic_lookup":"test_A_0"})
      recs_list = self.cur.fetchall()
      print
      print "lookup_first_field (test_A_0)" 
      for rec in …
woooee 814 Nearly a Posting Maven

main.cpp:1:20: error: Python.h: No such file or directory

Python.h is under /usr/include/pythonx.y on my Slackware box. If you don't have it then you will have to install the source.

woooee 814 Nearly a Posting Maven

No. Read the "We only give homework help to those who show effort" announcement http://www.daniweb.com/forums/announcement114-2.html Then take a look at one of the tutorials here http://wiki.python.org/moin/BeginnersGuide/NonProgrammers as this is the most basic of stuff that is in every tutorial and book.

woooee 814 Nearly a Posting Maven

I have absolutely no clue how to do it with a list of lists

test_matrix = [ ["A", "b", "c"], \
                ["R", "S", "s"], \
                ["X", "Y", "Z"] ]
for sublist in test_matrix:
   print sublist
   for ch in sublist:
      if ch == "S":
         print "\nS found in", sublist, "\n"
woooee 814 Nearly a Posting Maven

For timed events you generally use the "after" function.

from Tkinter import *
import datetime
import time

class ChangeTime(Frame):

    def __init__(self, master=None):
        master.geometry("100x50+5+5")
        Frame.__init__(self, master)
        self.pack()

        self.timestr = StringVar()
        lbl = Label(master, textvariable=self.timestr)
        lbl.pack()

        # register callback
        self.listenID = self.after(1000, self.newtime)

    def newtime(self):
        timenow = datetime.datetime.now()
        self.timestr.set("%d:%02d:%02d" % \  
                 (timenow.hour, timenow.minute, timenow.second))
        self.listenID = self.after(1000, self.newtime)


root=Tk()
CT = ChangeTime(root)
CT.mainloop()
woooee 814 Nearly a Posting Maven

The function has to return money and balance. Otherwise, money is changed in the function's memory and then abandoned when you exit the function, i.e. the memory used by the function is garbage collected. Take a look at the explanation of local variables here http://en.wikibooks.org/wiki/Python_Programming/Functions

woooee 814 Nearly a Posting Maven

You can put the redundant code into a function

def get_two_numbers():
    while True:
        try:
            x = float(raw_input("number one\n"))
            break
        except ValueError:
            print "Wrong input"
 
    while True:
        try:
            y = float(raw_input("number two\n"))
            break
        except ValueError:
            print "wrong input"
    return x, y

def add():
    x, y = get_two_numbers()
    print 'your answer is:', x+y
 
def substract():
    x, y = get_two_numbers()
    print 'your answer is:', x-y

I would also suggest adding some print statements, for example:

class wtd:#wtd= what to do
    command = raw_input("What do you want to do?\nadd +\nsubstract -\ndivide /\nmultiply *\n")

cmd1 = wtd()
print "cmd1.command =", cmd1.command
bull1 = cmd1.command
woooee 814 Nearly a Posting Maven

This statement will never be true
elif (data[x]>57 and data[x]<48):

woooee 814 Nearly a Posting Maven

This code works around using different names for the same variable, and using the same name for a function and a variable. You still have problems with your logic though but hopefully if will get you started in the right direction.

#THIS PART IS NOT THE CODE ITSELF THESE ARE JUST COMMANDS
def menu():
    money = 5000.00
    #print the options you have
    print "Welcome to the Python Bank System"
    print " "
    print "Your Transaction Options Are:"
    print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    print "1) Deposit Money"
    print "2) Withdraw Money"
    print "3) Check Balance"
    print "4) Quit Python Bank System.pyw"
    print
    return input ("Choose your option: ")

def deposit(balance, money):
    """ Here is the deposit part.... This is where the user inputs
         the amount of money they wish to deposit into their account.
    """
    deposit = input("How much: $")
    deposit = float(deposit)

    print "depositing balance = %7.2f,  money = %7.2f" % (balance, money)

    if deposit <= money:
        balance = balance + 1
        money = money - deposit
        money = float(money)
        deposit = deposit * .1
        deposit = float(deposit)
        balance = deposit + balance
        balance = float(balance)
        print "You've successfully deposited $", deposit, "into your account."
        print
        bank_balance(balance)
        return balance

#This is where the user inputs the amount of money they wish to withdraw from
#their account. Currently not programmed in as of yet.
def withdrawl(balance, money):
    print "Sorry, but this function is currently under construction!"
    print
    return balance

#This is an obvious one, this is where you check your balance.
def bank_balance(balance): …
woooee 814 Nearly a Posting Maven

There are many possible problems with this code, one of which is the following. Add some print statements to see what the program is doing.

def __radd__(self, other):
        print "__radd__ return =", self, other, type(self), type(other)
        return self + other
 
    def __rtruediv__(self, other):
        ## add a similar print  statement here
        return complex(other) / self
 
    def __rmul__(self, other):
        ## add a similar print  statement here
        return self * other
 
    def __rsub__(self, other):
        ## add a similar print  statement here
        return complex(other) - self

Also here

a = complex(2, 5)
    b = complex(1, 3)
 
    i = 4
 
    print type(a), type(b)
    print('%s + %s = %s' % (a, b, a + b))

I would suggest that you start with one function, let us say adding, get it to work and then go on from there as none of the code you posted will work.

woooee 814 Nearly a Posting Maven

This is an example I had using QLineEdit and QTextEdit. There are other ways to retrieve text based on starting and ending positions but I don't use it.

import sys
from PyQt4 import QtGui, QtCore

class GridLayout2(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.setWindowTitle('grid layout')

        title = QtGui.QLabel('Title')
        author = QtGui.QLabel('Author')

        self.title_edit = QtGui.QLineEdit()
        self.author_edit = QtGui.QTextEdit()

        grid = QtGui.QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(self.title_edit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(self.author_edit, 2, 1)

        c_button = QtGui.QPushButton("Continue")
        grid.addWidget(c_button, 3, 0)
        self.connect(c_button, QtCore.SIGNAL("clicked()"), \
                     self.button_click)

        quit_button = QtGui.QPushButton("Exit")
        grid.addWidget(quit_button, 3, 1)
        self.connect(quit_button, QtCore.SIGNAL("clicked()"), \
                     self.exit_widget)

        self.setLayout(grid)
        self.resize(250, 150)


    def button_click(self):
        print "button click called"
        print "self.title_edit", self.title_edit.text()
        print "\nself.author_edit"
        print self.author_edit.document().toPlainText()


    def exit_widget(self):
        self.button_click()
        self.close()

app = QtGui.QApplication(sys.argv)
qb = GridLayout2()
qb.show()
sys.exit(app.exec_())
woooee 814 Nearly a Posting Maven

A galactic year is 250 million Earth-years. This is the time it takes for our solar system to make one revolution around the Milky Way Galaxy.

There are mirrors on the moon. Astronauts left them so that laser beams could be bounced off of them from Earth. These beams help give us the distance to the moon give or take a few metres.

From NASA.gov
"Ringed by footprints, sitting in the moondust, lies a 2-foot wide panel studded with 100 mirrors pointing at Earth: the "lunar laser ranging retroreflector array." Apollo 11 astronauts Buzz Aldrin and Neil Armstrong put it there on July 21, 1969, about an hour before the end of their final moonwalk. Thirty-five years later, it's the only Apollo science experiment still running." http://science.nasa.gov/headlines/y2004/21jul_llr.htm (has a picture)

woooee 814 Nearly a Posting Maven

It's the same principle but using a function that knows the beginning point and how many letters to skip. You send the first list to the function with start_at = first letter, and skip =1 since you want to change every letter. You then send the second list with start_at = 1 or 2 depending on if you start counting with zero or one and skip = 3. The third list would start with 2 or 3 and skip 3, etc.

woooee 814 Nearly a Posting Maven

You draw an object like a circle and fill it with the color selected inside a try/except. It will fail if it is not a valid color. I think Tkinter uses an r,g,b tuple so your program should accept that as well as a name.

woooee 814 Nearly a Posting Maven

input is raw_input in 2.6

That's the only big difference along with Tkinter becoming tkinter. For print you can use either
print str
print(str)

and string.split(a) has been deprecated for while for all versions of Python, so use a.split() in all versions as well. There should be very few problems using 2.6 as it is a transition version that handles syntax either way in most cases.

woooee 814 Nearly a Posting Maven

This will change every 2nd letter to "x" and every 3rd letter to "y", but note that the 6th letter could become either "x" or "y" depending on the logic.

def change_chr(chr, x):
   if not x % 3:
      return "y"
   if not x % 2:
      return "x"
   return chr
   
mystring = 'bananasplit'
result = [change_chr(mystring[x], x+1) for x in range(len(mystring))]

print "".join(result) 

##prints bxyxnysxyxt
woooee 814 Nearly a Posting Maven

That's intentional, this macro is intended for long periods of time's use.

You will soon reach the maximum recursion limit. Use a while loop instead as Gribouillis suggested. Also, you can read the word file once into memory, shuffle it to some random order, and then take the words in groups of 4.

word_list = open("wordlist.txt").readlines()
random.shuffle(wordlist)

start = 0
go_on = ""
while go_on != "no":
    four_random_words = [word_list[x] for x in range(start, start+4)]
    start += 4   ## ready for next 4 random words 
    
    ## then send four_random_words to function to start Firefox
    
    ##  sleep for random time, 3 to 8 minutes
    time.sleep(random.randint(3, 8) * 60)
    go_on = raw_imput("Do you want to continue (yes or no) ")
    go_on = go_on.lower()
woooee 814 Nearly a Posting Maven

getRandEntry() calls startLink(theRandoms) which calls getRandEntry() which will create and infinite loop.

woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

You can use a dictionary as a counter, but you first have to convert the key to a tuple.

arr=[[10, 2, 10],
[10, 9, 10],
[10, 9, 10],
[10, 9, 10],
[10, 9, 10],
[22, 9, 10],
[10, 9, 10],
[10, 9, 10],
[22, 9, 10],
[10, 9, 10]]

unique_dict = {}
for x in arr:
   ## convert to a tuple so it is hashable
   y = tuple(x)
   if y not in unique_dict:
       unique_dict[y] = 0
   unique_dict[y] += 1

print unique_dict
woooee 814 Nearly a Posting Maven

First, try running this code in Idle. It will tell you that there are problems with this statement with a variable name that contains special characters.
Starting_weight_of_food_in_lbs{:}ozs=input("Enter Starting_weight_of_food_in_lbs{:}ozs")

Take a look here for getting started with Idle http://www.ai.uga.edu/mc/idle/index.html

woooee 814 Nearly a Posting Maven

+1 for "Dive Into Python" and "Think Like A Computer Scientist" For the non-programmer, something like this might be better as it explains the logic behind things like while() loops, etc.
http://www.pasteur.fr/formation/infobio/python/

woooee 814 Nearly a Posting Maven

but import statement imports it only once and i have no clues how to fix it.

Why do want to import the same thing a second time? You already have it in memory. Putting the same thing in another block of memory is a waste.

To test for a number, there are several ways to do it. The simplest to understand is to test each character of the input for >= "0" and <= "9". Take a look at the first part here for iterating over a string. http://www.pasteur.fr/formation/infobio/python/ch11s02.html

woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

File "./ste.py", line 64, in disconnect
self._conn.close()
_mysql_exceptions.ProgrammingError: closing a closed connection

Why are you closing a connection (twice) for a db that you are adding records to. How about some code. Also, you do not have to commit after every add, so wait until after you have added x records, which may also be part of the problem. Also, it could be a log file that is full. The workaround is to add some number of records, then close the db, open it again, add some more records, etc. but that is only if all else fails. Please post any solutions you find as this is the kind of thing that can waste hours trying to track down.

woooee 814 Nearly a Posting Maven

To use the AgeName class instance, with the name in the dictionary pointing to each class instance, you could do something like this.

from math import sqrt
class AgeName:
    """class to represent a person"""
    def _init_(self):
        ## 'name' is redundant since it is the key of the dictionary
        ##self.name = ""
        self.age = 0.0
        self.sqrtage = 0
 

def print_all(name_dict):
   for name in name_dict:     ## each key in the dictionary
      print name, name_dict[name].age, name_dict[name].sqrtage


name_dict = {}
name = "" 
while name != 'stop':
    name = raw_input("Enter a name, or stop to exit: ")
    if name.lower() != 'stop':
        ##  name_dict[name] now points to a class instance
        name_dict[name] = AgeName()
        name_dict[name].age = int(raw_input("Enter an age: "))
        name_dict[name].sqrtage = sqrt(name_dict[name].age)
        print name, name_dict[name].age, name_dict[name].sqrtage
print_all(name_dict)
woooee 814 Nearly a Posting Maven

The first two posts found in a search of this forum, after your post which is the first/latest, have working solutions that you should be able to adapt.

woooee 814 Nearly a Posting Maven

the first phase will read in the file and find all of the tags and save them into a queue

Wouldn't that just be a list or a dictionary.

the second phase will take in the queue of tags from the first phase and check to see if they are balanced and then print the output.

You can read the stored list, check if each item is an opening tag, search for the corresponding closing tag, and delete both (use a copy of the list if you want to keep the original), and increment a counter if you want to keep track. Whatever is left is what was not matched, either opening or closing tags. Note that in the example file you posted, there were no opening or closing tags so it is difficult to tell what you are working with. If you post the file again, use "[code]" tags to preserve everything, since HTML is scripting code.

woooee 814 Nearly a Posting Maven

The problem I have is after I did the rstrip(), nothing really happened to the text file? I don't really know what I'm missing.

You have to write the data to a file. You read the disk file into memory, change it in memory and then exit the program. If you want the file in memory saved to disk, then use "write" in addition to "read". http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap11.html

woooee 814 Nearly a Posting Maven

Note the form of this
[1, 0.1, 0.2, 0.3]
[0, 1, 0.4, 0.5]
[0, 0, 1, 0.6]
[0, 0, 0, 1]

that is, part one =
[1 ]
[0, 1 ]
[0, 0, 1]
[0, 0, 0, 1]

part two =
[ 0.1, 0.2, 0.3]
[ 0.4, 0.5]
[ 0.6]
[]

Do the first part, appending an extra zero each time, and then append the second part which is just a counter counting from 0.1 up. But to make it more difficult, you have to append one less item each time. For the first part

matrix = []
for y in range(0,4):
   single_list = [0 for x in range(y)]
   single_list.append(1)  
   print "appending", single_list
   matrix.append(single_list)
print matrix
woooee 814 Nearly a Posting Maven

fetching data from qt

The short answer is to look at QLineEdit here http://www.devshed.com/c/a/Python/PyQT-Input-Widgets/ More tutorials are on the wiki http://www.diotavelli.net/PyQtWiki/Tutorials

woooee 814 Nearly a Posting Maven

I don't think that anyone here is going to give you code that you can take to another forum, claim it is yours, and ask them to finish it for you. Let this thread die.

woooee 814 Nearly a Posting Maven

I would suggest two classes, one that handles the physical details of the SQL database and one for everything else. So, if you want to modify a record, the second class would generate a GUI to ask for info on the record. The info would be passed to the SQL class' lookup function, which would pass the record back. You use a separate class for the SQL functions to have the option of using more than one program to access the database. They would all use the same SQL class so would all have tested routines and would not yield an error in this program but not in that program.

woooee 814 Nearly a Posting Maven
if clickx>=iris1x and clickx <=iris2x and clicky>=iris1y and clicky<=iris2y:

If you are dealing with eyes, etc. that are circles then your test doesn't work. I think you would have to
1. take the distance of the mouse-click x-coordinate from the center of the circle
2. make sure the difference is less than the radius
3. do the same for the y-coordinate
4. use the distance from the x-coordinate to the center, as the base of a right angle triangle, and then calculate the y distance to the edge of the circle, using the radius as the hypotenuse, and of course in both directions since one can be closer to the edge.
5. check that the length found in #3 is less than #4

Just create one function and pass the center point, radius, and mouse x,y. You can then use 2 function calls at most to tell if it is in the eye or outside, and if in the eye, in the iris or outside.