woooee 814 Nearly a Posting Maven

Good to hear. Please mark the post as solved. If you have more problems, start a new thread.

woooee 814 Nearly a Posting Maven

I dont want to remove the old data in the file just add new data to it?

Opening a file in write mode creates new file. You want to open in append mode. A Google for 'Python file append' will give all the info you want to know.

import random
testfil=file("testfil.txt","r")      ## opened for reading once only
fp_out = open('testfil.new', "a")
n = 10
for rad in testfil:
    if  n >= 0:
        x = random.randrange(0,100,1)
        print rad, x
        fp_out.write("%d\n" % (x))
        n = n-1
       
## file closed once only, not once for every loop
testfil.close()
fp_out.close()
woooee 814 Nearly a Posting Maven

Do you have to find up and down as well? If North is (5,5), and you are using a dictionary, you can easily look up (5,7) etc. instead of the list comprehension.
print coord_dict[(5,7)]
instead of
East = [e.color for e in objectList if (e.coord[0] == object.coord[0] + 2 and e.coord[1] == object.coord[1])]

You will add one and subtract one from the first number, and do the same for the second, giving you the four neighbors (if you don't want up or down = 6 directions). And are you sure that you want +2 instead of +1? Again, if North is (5,5) and you are looking for (5,7), what is (5,6)? Finally, if all else fails, store the neighbors coordinates in another dictionary so you can look up the original coordinate, and it will point to a list of the coordinates of all neighbors.

woooee 814 Nearly a Posting Maven

Does nobody read my posts? \b matches the word boundary. A regexp '\bnf\b' does exactly what the OP wants.

We do read the original post.

also re.sub('\bnf\b', '1.0', str) does not work either as 'nf' can be anywhere in the string.

And as we do not know the before string, or whether or not there is always a "+" associated with it, we have to make assumptions.

woooee 814 Nearly a Posting Maven

Rather tedious, but one more way.

nf_str = 'nf+nfpermult+nf+nf'
ctr = 0
index = -1

go_on = True
while go_on:
   print nf_str
   before = False
   after = False

   index = nf_str.find('nf', index+1)
   if index > -1:
      ## check character before
      if (index == 0) or (not nf_str[index-1].isalpha()):
         before = True

      ## check character after
      if (index+2 >= len(nf_str)) or \
         (not nf_str[index+2].isalpha()):
         after = True

      if before and after:   ## neither is alpha
         nf_str = nf_str[:index] + "1.0" + nf_str[index+2:]

   else:          ## 'nf' not found
      go_on = False
   ctr += 1

print nf_str 

"""  my results
nf+nfpermult+nf+nf
1.0+nfpermult+nf+nf
1.0+nfpermult+nf+nf
1.0+nfpermult+1.0+nf
1.0+nfpermult+1.0+1.0
1.0+nfpermult+1.0+1.0
"""
woooee 814 Nearly a Posting Maven

string.replace(" nf ","1.0")?

Your question is not clear because you show the after but not the before.

woooee 814 Nearly a Posting Maven

What type of objects does the query return? You may have to convert to a list to access it in this way.

query = db.GqlQuery("SELECT *" .....etc.
print type(query)
ctr = 0
for q in query:
    if ctr < 2:
        print type(q)
    ctr += 1
woooee 814 Nearly a Posting Maven

This is a more or less standard way of entering data. Use a function, and return from the function only if a correct value is entered.

def colour_picker():
    colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"]
    print "pick four different colours from;",
    print ",".join(colourList)

    while True:
            colourPicked = raw_input("pick a colour: ")
            if colourPicked in colourList:
                return colourPicked
            print "not in list, pick again: "


chosenColours = []
for x in range(4):
        colour_returned = colour_picker()
        chosenColours.append(colour_returned)
print chosenColours
woooee 814 Nearly a Posting Maven

Add some print statements so you know what is going on.

def colourpicker():
    print "pick four different colours from; red, green, blue, yellow, orange, pink, brown"
    colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"]
    coloursPicked = []
    while True:
        colour1 = raw_input("pick first colour: ")
        print "colour1 picked =", colour1

        if colour1 in colourList:

            print "colour1 in colourList"
            break
        colour1 = raw_input("not in list, pick agin: ")
    coloursPicked.append(colour1)

    print "returning", coloursPicked
    return coloursPicked

    ##  etc. 
    ## consider using one function and calling it 4 times for the colors
woooee 814 Nearly a Posting Maven

Inside this Class, there is another Class

Why is this necessary. Everything should be in functions inside a single class, or two classes with one calling an instance of the other.

TclError: image "pyimage8" doesn't exist

You are probably looking in the wrong directory. Use the absolute directory + file name for the image = /path/to/images/choose.gif

## missing a quote on the following line
photocho = PhotoImage(file=choose.gif")
                self.labelcho = Button(framebu, image= photocho)
                self.labelcho.image = photocho

                ##---------------------------------------------------------------
                ## you can not use grid and pack.  Pick one only
                self.labelcho.pack()
                self.labelcho.grid(row=2, column=0)

Effbot's Photoimage page http://effbot.org/tkinterbook/photoimage.htm

For any more help you will have to post some code.

Ash_Pokemaster commented: Thanks man +0
woooee 814 Nearly a Posting Maven

The same code with a call back to show which button was pressed. Hopefully you will use a class structure for this as that eliminates shared variable problems.

from Tkinter import*

def cb_handler(event, cb_number ):
    print "cb_handler - button number pressed =", cb_number

root = Tk()
frame = Frame(root)

frames = []
buttons=[]
for i in range(24):
    f = Frame(frame)
    frames.append(f)
    for j in range(25):
        n = 25 * i + j
        b = Button(f, text= "%03d" % n)
        buttons.append(b)
        b.pack(side="left")

        def handler ( event, button_num=n ):
            return cb_handler( event, button_num )
        b.bind ( "<Button-1>", handler )

    f.pack(side="top")
frame.pack(side="top")

root.mainloop()

It's all personal preference, but I prefer a grid.

from Tkinter import*

def cb_handler(event, cb_number ):
    print "cb_handler - button number pressed =", cb_number

root = Tk()
frame = Frame(root)

buttons=[]
b_row=1
b_col=0
for j in range(1, 601):
         b = Button(frame, text = "%3d" % (j))
         buttons.append(b)
         b.grid(row=b_row, column=b_col)

         def handler ( event, button_num=j ):
                return cb_handler( event, button_num )
         b.bind ( "<Button-1>", handler )

        ## you can also use 2 for() loops as Gribouillis did
         b_col += 1
         if b_col > 24:
            b_col = 0
            b_row += 1

frame.grid(row=0, column=1)
root.mainloop()
woooee 814 Nearly a Posting Maven

The problem might be the double "input" on the previous line. You did not state that there was an error in the first post, and to get any more help you will have to post the exact error message as well.

if option==1:
        whatsdaradius(input(input("enter a circumference: "))
    if option==2:
        radius2pie(input("enter a radius (ie.half diametre): "))
woooee 814 Nearly a Posting Maven

One thing, you can not open a directory, so you should test that it is a file.

import os
a = []
a = os.listdir('.')
for t in a:
    if os.path.isfile(t):
        f = open(t,'r')
        print t, "opened"
        f.close()
    else:
        print "     ", t, "not a file"

Also, if you are not using Idle for writing code, http://www.annedawson.net/Python_Editor_IDLE.htm that is the editor/IDE that you want to start with. You can choose from several other options once you know what you want in an IDE.

woooee 814 Nearly a Posting Maven
if option==3:
        active<>"on"

This will print "True" if active != 'on' and print "False" otherwise. <> has been deprecated so use "!=" instead. I think you want

if option==3:
        active = "off"

Also you can simplify the following code.

if option<>1 or option<>2 or option<>3:
        ondamenu()
##
## can also be written as
    if option not in (1, 2, 3):
        ondamenu()
woooee 814 Nearly a Posting Maven

First you want to check that the word ends up as an even number, otherwise you can't divide it in two. Tiger = 59 so is not a good choice.

import string


def number_equiv(word):
    ## I prefer a list over string.find  (so sue me)
    letters_list = [ ltr for ltr in string.lowercase ]
    total = 0
    for ltr in word:
        num = letters_list.index(ltr) + 1
        print ltr, num
        total += num
    print total

number_equiv("tiger")
number_equiv("tigers")

Next, I would think that you would want to start with the largest number since it is the most inflexible. For "tigers" that would be t=20. Since "tigers" adds up to 78, one-half would be 39. 39 -"t"(20) = 19 which is "s" which you have, so "tigers" = "ts" and "iger". In this case, I think that is the only solution.

woooee 814 Nearly a Posting Maven

You aren't converting to a float. Try this code to emphasize the point.

h_list = [ 1, 2, 3 ]
k_list = [ 2, 3, 4 ]
for h in h_list:
   for k in k_list:
      print h,k, (h/k) * 100, "----->", float(h)/k
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

'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

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

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

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

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

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

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

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

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

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

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

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

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

A quick example of a spiral using deque. It still has a few problems (works best with a square and prints too many) but shows the general concept.

from collections import deque

##========================================================================
def print_spiral( total_cols, total_rows ) :
   d_list = []  ## hold pointers to separate deque objects
   for j in range( 0, total_rows ) :
      d_list.append( deque( ) )

   ##  find center square
   this_row = total_rows / 2
   d_list[this_row].append( 1 )

   num_ctr = 1   ## the number to print
   incr = 1      ## 1 for first 10, 2 for second 10, etc
   num_cols = 1  ## number of columns to print for this row for this pass
   stop = total_rows
   x_dir = True  ## True  = + direction (right for x, down for y)
   y_dir = True  ## False = - direction (left for x, up for y)

   for j in range( 0, total_rows ) :
      x_dir = not x_dir

      ## for this row, increment the number and add to each column
      ## in this row, either left to right, or right to left
      for k in range( 0, num_cols ) :
         num_ctr += incr
         if incr <= total_rows :
            if x_dir == True :
               d_list[this_row].append( num_ctr )
            else :
               d_list[this_row].appendleft( num_ctr )

      ## increment the number and add one to row, or subtract one
      ## depending on the direction
      y_dir = not y_dir
      for k in range( 0, num_cols ) :
         num_ctr += incr
         if incr <= total_rows  :
            if y_dir == True :
               if this_row …
woooee 814 Nearly a Posting Maven

Start by asking the player(s) for a name and store it in a dictionary that will also keep track of their score. Then, open one graphic window that will simply display the name and score of the player(s). Worry about the multiple windows and clicking on each at a latter time. The design will be both easier and better if you use a class structure for this. Post the code here and ask for help for any glitches.

woooee 814 Nearly a Posting Maven
if "EMERGENCY" or "Help" or "!" in heading:
   pass
elif ("no idea" in body) or (not Code() in body):
   pass
lllllIllIlllI commented: Like the only original poster in the thread :S +2
woooee 814 Nearly a Posting Maven

I think you could check for a number in the second position, if I understand correctly that overlays use numbers and updates/adds use a letter.

if len(line.strip()) and \
   not line.startswith("Found") and \
   not line[1].isdigit():
pizte commented: Clear and concise. Self explainable. +0
woooee 814 Nearly a Posting Maven

So i searched the sys.path for 2.6 and included
usr/lib/python2.6/dist-packages
in python3 sys.path

So you are obviously using PyQT4 built for Python 2.6. The error message confirms it.

undefined symbol: PyString_FromString

Ask how to install PyQT for both 2.6 and 3.x on the Ubuntu or PyQt forum. Some one has done this and if there isn't anything in the repositories then there is probably a deb package that someone has made. Otherwise you will have to build from source against Python 3.x The good news is that if you screw up things, you can just re-install PyQT and get back to where you are now.

woooee 814 Nearly a Posting Maven

Python does not have static variables, but does have global variables, which those are not. They are class objects and would be called using
Atom.cartesian
both inside and outside the class. In this simple example, note that cartesian belongs to the class and not the instance of the class:

class Atom:

    cartesian = 1

    def __init__(self):
        self.atom_name = "atom name"

    def print_cartesian(self):
        print "cartesian =", Atom.cartesian

print Atom.cartesian  ## --> 1
try:
    print Atom.atom_name  ## AttributeError: class Atom has no attribute 'atom_name'
except:
    print

Atom.cartesian += 1
x = Atom()
print Atom.cartesian
print x.atom_name
x.print_cartesian()