woooee 814 Nearly a Posting Maven

Depending on the version of Python you are using, this may or may not return a string
hours = input("How many hours did they work?: ")
If it is a string and not a float
print type(hours),
the function should
return float(hours)
Hopefully, it is obvious why you want to do this.

woooee 814 Nearly a Posting Maven

You would use a dictionary to convert.

convert_dic = {"I":1,
               "V":5,
               "X":10,
               "L": 50,
               "C ":100,
               "D": 500,
               "M": 1000 }

Also, this line should be "equal to or greater than".
if romaninput[0] > romaninput[1]:

Better yet, use a for loop to iterate through all of the roman numerals. Sorry if this is harsh, but if the above code is all you have, you'd should start reading the text book immediately and find out
1. How to enter the roman numeral from the terminal
2. Use a for() loop to examine each letter
3. How a dictionary works

woooee 814 Nearly a Posting Maven

Start with just this part and post the code here.

Using a loop, allow the user to input as many student names as they like

woooee 814 Nearly a Posting Maven

You are over-thinking this

list_n = [[3, 2], [5, 1], [4, 7]]
print "Before",  list_n
for j in range(0, len(list_n)):
   row = list_n[j]
   row.append(0)   ## can also use just list_n[j].append(0)
print "After ", list_n
woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

I think you just want a simple menu program

def func_a():
   print "     hello world import"
def func_b():
   print "     hfile import"

##-------------------------------------------------------------------
menu_d = { "awesome1":'func_a()', 
           "/help":'func_b()'} 
choice = ""
while choice not in menu_d:
   choice = raw_input("type /help to continue or the password:\n ")
   if choice in menu_d:
      eval(menu_d[choice])
   
print "\nend of program"
woooee 814 Nearly a Posting Maven

This online book has a good explanation of arguments http://en.wikibooks.org/wiki/Python_Programming/Functions After that, the best way to learn is to try a few things yourself, print the results, and see what is happening.

woooee 814 Nearly a Posting Maven

You can specificy a different delimiter. The code below is from the official docs. But for an either/or situation, if you don't want to write your own routine, the easiest is probably reading each file, replacing a semicolon with a comma if found, and writing to a new file. Then use csv to process the new file.

import csv
spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|')
for row in spamReader:
     print ', '.join(row)
Spam, Spam, Spam, Spam, Spam, Baked Beans
Spam, Lovely Spam, Wonderful Spam
woooee 814 Nearly a Posting Maven

Also note that in the following code you convert to upper case after testing for an upper case letter. You want to convert to upper() once only directly after the input.

if userit == A:
            userit = userit.upper()
            print ("\n  Thats good. I like it too ") ,userit ,

This can be replaced with a dictionary if you want. This is especially good when you have a lot of options.

if userit == A:
            userit = userit.upper()
            print ("\n  Thats good. I like it too ") ,userit ,
 
        elif userit = B:
            userit = userit.upper()
            print ("\n  really what ever you say ") ,userit ,
        elif userit = C:
            userit = userit.upper()
            print ("\n  Thats bad ") ,userit ,
        else:
            print ("\n  Please enter from the Above options ") ,userit
# 
#---  Replace with (code not tested)
python_dic = {"A":" Thats good. I like it too ",
                       "B":" really what ever you say ",
                       "C":" Thats bad "}
userit = "X"   ##  gets us into the while loop
while userit not in python_dic:
     userit = raw_input(" Do you like python? (A=its Great, B=its Ok, C=its Rotten)")
     userit = userit.upper()
     print 
     if userit in python_dic:
          print python_dic[userit], userit,
     else:
          print ("\n  Please enter from the Above options ") ,userit
woooee 814 Nearly a Posting Maven

Also, add the code for how you call these functions if you post again. Some errors are simply caused by a function not being called with parameters, etc. and since you don't print or return from "sides" there is a potential problem there as well.

Edit: I see that you may or may not be getting the values for the sides outside the function depending on the indents. Do you want to call both functions from there? There is also a problem in what variables you are sending to the functions. halfPerimiter is not correct (other than the spelling of perimeter).

def sides (firstSide, secondSide, thirdSide):

def halfPerimiter(s):
   s = (firstSide + secondSide + thirdSide)/2.0
   print halfPerimiter

firstSide = raw_input ("Length of first side? ")
firstSide = float (firstSide)
secondSide = raw_input ("Length of second side? ")
secondSide = float (secondSide)
thirdSide = raw_input ("Length of third side? ")
thirdSide = float (thirdSide)

sides (firstSide, secondSide, thirdSide)
woooee 814 Nearly a Posting Maven

If you are looking for alternating colors in a checkerboard fashion, use bg & fg + the color. You might also want to check the canvas widget. It may be overkill though http://infohost.nmt.edu/tcc/help/pubs/tkinter/create_rectangle.html

# import all the Tkinter methods
from Tkinter import *
       
# create a window frame
frame1 = Tk()
# create a label
label1 = Label(frame1, bg="white", fg="black", \
               text="Hello, world! How are you doing today?")
label2 = Label(frame1, bg="black", fg="white", text= "hi smiley")
# pack the label into the window frame
label2.pack(side="left")
label1.pack(side="left")
frame1.mainloop()
# run the event-loop/program
woooee 814 Nearly a Posting Maven

The problem may be that you are using the reserved word "file" and perhaps overloading it. file and open are basically the same for Python. So use something other than "file", check the contents of the output file with a text/word processor to see that it is really there 3 times, and post back if the problem doesn't disappear.

sneekula commented: good catch +6
woooee 814 Nearly a Posting Maven

There's also a second part where I should define a SortedSet class

Verify with the teacher that the set will only contain integers, floats, and strings, and whether there will be more than one type of these in the set.. If you have lists mixed in with integers mixed in with whatever, sorting gets very tricky.

sneekula commented: very good point +6
woooee 814 Nearly a Posting Maven

With Tkinter (if you are using Tkinter) it would be something like
text.insert(INSERT, "click here!", "a") or
listbox1.insert() As for "refreshed automatically", there is nothing automatic. You will have to define what event causes a refresh. You can tie it to a button press or a file write, etc. Any event or events, but those have to be declared. Pythonware has some nice Tkinter docs. This is for text boxes http://www.pythonware.com/library/tkinter/introduction/text.htm#AEN7880 Also, Vegaseat posted some example code on this forum http://www.daniweb.com/code/snippet594.html From that link (note the third entry):

# load a Tkinter listbox with data lines from a file,
# sort data lines, select a data line, display the data line,
# edit the data line, update listbox with the edited data line
# add/delete a data line, save the updated listbox to a data file
# used a more modern import to give Tkinter items a namespace
# tested with Python24 vegaseat 16nov2006

woooee 814 Nearly a Posting Maven

Two or three print statements should do the trick. Note that string is no longer used. It should be linea=linea.split(';') instead of linea=string.split(linea,';'), etc.

fINI='f:\\pulldpto.ini'
fINI=open(fINI,'r')
while 1:
   linea=fINI.readline()
   if not linea:break
   linea=string.split(linea,';') 
   print "linea after split =", linea
   print "     setting", variabl1[string.strip(linea[0])], "to zero"
   variabl1[string.strip(linea[0])]=0
   print "     setting", variable3[string.strip(linea[0])], "to", string.strip(linea[1])
      variable2[string.strip(linea[0])]=string.strip(linea[1])
fINI.close()
woooee 814 Nearly a Posting Maven

In 1221 Genghis Khan killed 1,748,000 people at Nishapur in one hour.

That is too fantastic to believe. 1000 soldiers would have to kill 1748 people in one hour, and 10,000 would still have to kill 174.8 in one hour. And that's not even mentioning how difficult it would be to find that many people who are in hiding (unless they were really, really dumb). That number of people may have disappeared as a result of being conquered, but many probably relocated out of fear. It sounds more like a horror story spun by the conquered, or Genghis Khan himself to instill fear. If anyone less lazy than me wants to dig up anything more on this, please post it.

GrimJack commented: Good call! I agree +9
woooee 814 Nearly a Posting Maven

Is this possible? The original text file will be around 100Mb and have maybe 100 parameters.

Were you able to do this with the suggestions posted?

woooee 814 Nearly a Posting Maven

This will add a second line where necessary. How you process the data depends on what you want to do with it. Is it this just to rearrange and write to a file? If so the following code, with a few modifications to take into account the lines not processed by it, should work. If not post back with specifics.

This code uses a dictionary of lists, and should be self-explanatory. There are 2 functions, one to process the "NAME=" record, and a second to append additional data. The trick is to pass the existing dictionary and key to the append function. The code also creates an empty dictionary before processing the next "NAME=" record. If you are comfortable using a class, this code would be a good candidate. Keeping track of the variables is easier IMHO.

"""-----------------------------------------------------------
test file contains this data subset

MATERIAL
NAME=STEEL IDES=S W=76819.55
T=0 E=1.99948E+11 U=.3 A=.0000117 FY=3.447379E+08
NAME=CONC2 IDES=C W=23560
T=0 E=2.48211E+10 U=.2 A=.0000099
NAME=OTHER IDES=N W=76819.55
T=0 E=1.99948E+11 U=.3 A=.0000117
NAME=CON3 IDES=C W=23560
T=0 E=2.48211E+10 U=.2 A=.0000099

FRAME SECTION
NAME=CON450X450 MAT=CONC2 SH=R T=.45,.45
NAME=FSEC1 MAT=CON3 SH=P T=.3048
NAME=B200 MAT=CONC2 SH=R T=.16,.2
NAME=B300 MAT=CONC2 SH=R T=.16,.3
NAME=B400 MAT=CONC2 SH=R T=.16,.4
NAME=B400H MAT=CONC2 SH=R T=.16,.4
"""

def append_rec_list(rec_in, return_dic, key):
   conditions = rec_in.split()
   print "     appending", conditions
   for each_c in conditions:
      sub_conditions = each_c.split("=")  ## a list with 2 elements
      return_dic[key].append(sub_conditions)
   return return_dic
  
def new_rec_list(rec_in, dic_return):
   conditions = rec_in.split()
   print "     record was split into", conditions
   name, key = conditions[0].split("=")   ## split first …
woooee 814 Nearly a Posting Maven

Also, you might also be able to use checkbuttons within each square for the GUI mode. The person would check the square they want. The checkbutton number would equal the square number. Just a thought on how it might be easier to use a GUI. But first things first = get the logic for handling the squares down. As the old say goes, first make it work, then make it fast, then make it pretty.

woooee 814 Nearly a Posting Maven

You can use a dictionary to store the moves. The square number would be the key, so let's say it is 1 through 9. You can then ask the person which square they want to occupy if using console input. If using a GUI, you would test for the location of the cursor, already knowing the boundaries of the squares. The value for each key (1->9) in the dictionay would be initialized to zero. If the "X" person is number 1 and the "O" person is number 2, then you would modify the dictionary with the corresponding person when they choose a square. You can also initialize to an empty string and modify with the actual "X" or "O". And that might be easier when printing as you would just print the contents of the dictionary instead of testing for 1 and print an "X" if true. To state the obvious, if the square number in the dictionary is not zero (or is not an empty string), the square is occupied

woooee 814 Nearly a Posting Maven

Do you just want to extract the values for the "MATERIAL" and "STEEL" or do you want all values under "MATERIAL"? Ditto for "FRAME" and "SHELL". You would test for "MATERIAL" or "FRAME" and then extract depending or which catagory it is, and use a dictionary to store the values, with "CON450X450", etc as the key.

woooee 814 Nearly a Posting Maven

A list of python books online http://linkmingle.com/list/List-of-Free-Online-Python-Books-freebooksandarticles
Also, Doug Hellmann's "Python Module of the Week" is excellent http://www.doughellmann.com/PyMOTW/
But if you want to know something specific, this is the place to ask.

woooee 814 Nearly a Posting Maven

There are two separate parts of course. Start with the logic
1. How are you going to identify the individual squares, by row and column, or will each square have a unique number. And how will you test to see that the square is not already occupied, which will be necessary if playing against the computer (and people who try to cheat).
2. How will you store the moves so you can test for a tic-tac-toe
3. Will input be a separate entry box, and if so you will have to communicate between the two, so to start, test with console input only.

woooee 814 Nearly a Posting Maven

The general idea is to store the replacement values in a container like a dictionary, isolate the string that you want to test, and replace it if it is in the replacement dictionary. As stated above you could store them in a separate text file and read into a dictionary. The following code uses a list for input and output to simulate files, but gives the general idea.

class Param(object):
   def __init__(self):
      ##   parameter dictionary with the key=string to search for,
      ##   and value=replacement value
      self.params_dic={"param1":"3",
                       "param2":"2",
                       "param3":"1" } 


   def process_file(self, data_in):   
      output_list = []
      for rec in data_in:
         r_list = rec.split("=")
         test_s = r_list[1].strip()
         if test_s in self.params_dic:     ## found
            output_list.append("%s=%s\n" % \
                                        (r_list[0], self.params_dic[test_s]))
         else:                               ## not found
            output_list.append(rec)

      print "final output ="
      for rec in output_list:
         print rec,

P = Param()
input_file_list = ['a =1\n', 'b=2\n', 'c= param1\n', 'd=4\n', 'e=param3\n']
P.process_file(input_file_list)
woooee 814 Nearly a Posting Maven

I hope you also took the suggestion to add the print statement for testing. And random.randint should use 1 & 6 (sorry, my mistake). But in the following code you have that statement twice, with different values for each. The second time will never be used. At the start of the next loop, the statement directly after the while() statement will overlay it with a new value for roll. The program is a little too verbose but does the job and that's what counts.

while (dice < r):
    while (counter < n):
        roll = random.randint(1,6)
        if roll == 1:
            one += 1
            if one > 0:
                print "1"
                f.write('1,')
##   these 3 statements are the same for every if/else and
##   so should be deleted from here and all of the other
##   elif.  You can use one set of  these statements after 
##   all of the if/elif since they are to be executed no
##   matter what the value of roll is.
                time.sleep(.2)
            counter += 1
            roll = random.randint(0,7)   ##  redundant 2nd statement
woooee 814 Nearly a Posting Maven

It could very well be overkill depending. Some more info would help, but I would suggest that you start with some of your own code to find out what you want and don't want to do. Once some of the parameters are defined, it will be an easier decision.

woooee 814 Nearly a Posting Maven

Put the roll statement under one of the while loops
roll = random.randint(1,6)
Now, it is only executed once at the beginning of the program. Also, instead of all of the if/elif you can use a list or dictionary and increment, for example
counter_list[roll] += 1
You will have to initialize it to zero first of course, where you are now initializing the 6 counters. Finally, the "if one > 0" statement is not necessary. The counter will always be greater than zero since you add one on the previous line

while (dice < r):
    while (counter < n):
        if roll == 1:
            one += 1
            if one > 0:
                print "1"
                f.write('1,')
                time.sleep(.2)
            counter += 1
#
#   so you can just do something like
while (dice < r):
    while (counter < n):
        ##   also I would __strongly__ suggest adding this print statement
        print "inner while loop = %d of %d" % (counter, n)
        roll = random.randint(0,7)
        counter_list[roll] += 1
        print roll
        f.write("%d\n" % (roll))
        time.sleep(0.2)
        counter += 1
woooee 814 Nearly a Posting Maven

While you can use a single or double quote within Python, databases are not so forgiving. If Jim699's post works it is because of the different use of quotation marks. If that doesn't work, try

SQL_str = 'INSERT INTO table (column1, column2) VALUES ("start finish","now later")'
cursor.execute(SQL_str)
woooee 814 Nearly a Posting Maven

This is the easiest way to understand that I can think of for printing 6 across. One while loop, no multiple for loops. You should decide how the user will pick the column and row that they want, unless I missed it in your code (obviously, a 6x6 matrix will be easier to determine row and column).

words = [ "one", "two", "three", "four", "five", "six", "seven", \
          "eight", "nine", "ten", "eleven", "twelve", "thirteen", \
          "fourteen", "fifteen", "sixteen", "seventeen", "eighteen" ]
ctr = 0
while ctr < 18:
   print "%-11s" % (words[ctr]),     ## note the comma
   ctr += 1
   if ctr % 6 == 0:
      print     ## newline
woooee 814 Nearly a Posting Maven

Also you probably want to indent everything under __main__, as well as use something other than "list" as a variable name as it is a reserved word. The way you have it, the code under __main__ is executed, and when finished, the wihile loop is executed, If it makes it easier to understand, create another function to ask the user. Finally, note that the end number is not tested which may or may not be what you want.

if __name__=='__main__':
   dummy = "y"
   while dummy == "y":
       s = input('Enter Start: ')
       e = input('Enter End:   ')
       s|=1                               #if s%2==0:s+=1   
       list_prime = [x for x in range(s,e,2) if isPrime(x)] 
       print "list of prime numbers", list_prime
       print "type y/n to go again or not"
       dummy = raw_input('again (y/n): ').lower()
woooee 814 Nearly a Posting Maven

loop over all files(named output10000 - output10000000)
get all the values at all positions

For this example of data
2.825 1.00697992588
2.875 0.952989176901
2.925 0.91428970229
2.975 0.890110513425
If it is the first number, "2.825", that you want to use as the key with the second number being the values, I would suggest using a dictionary of lists with "2.825" as the key, and appending the "1.00697992588" to the list for that key. You can then sum each list and average. So, assuming that all of the data will fit into memory:

input_data = [ "2.825       1.00697992588", \
               "3.005       0.91428970", \
               "2.925       0.91428970229", \
               "2.825       0.952989176901", \
               "2.925       0.890110513425" ]

ave_dic = {}
for rec in input_data:
   key, value = rec.strip().split()
   if key not in ave_dic:
      ave_dic[key] = []
   ave_dic[key].append(value)
for key in ave_dic:
   print key, ave_dic[key]

Finally, you may want to use Python's decimal class instead of float() if float is not accurate enough.

woooee 814 Nearly a Posting Maven

Optionally, unless the requirements specifically require that you use a 6 by 6 matrix

I found that odd as well. Perhaps you should re-read the problem and make sure that it requires a 6x6. The 6X6=36 evidently comes from 18 words X2 = unscrambled and scrambled, in which case there would be 2 lists, one for the unscrambled and one for the scrambled. Anyway, if you haven't solved it yet, post back with a little more info.

woooee 814 Nearly a Posting Maven

but i do not know how to seperate the whole file into the 49 different months. and thake their averages.

I'm not going to read the whole problem; it's way too long. Post some sample input data and state specifically what you do not understand. In the code you posted, it is already a list of lists so you should be able to loop through it one record at a time and calculate an average (using a total field, which is the grand total of all the values, and a num_records field which is the total of the number of records used), but it's not clear whether this is data for Google only, or you have to extract the data for Google from the rest, and then calculate the average.

woooee 814 Nearly a Posting Maven

You would use a [6][6] list of lists.

list_6x6=[]     ## outer 'matrix'
   junk = []
   for k in range(0, 6):                   ## inner list with length=6
      junk.append(j*6 + k)
   list_6x6.append(junk)

for single_list in list_6x6:
   print single_list

Also, you can use a dictionary instead of those if/elif.

if bok =='A';
            index = 0
        elif bok == 'B';
            index = 1
        elif bok == 'C';
            index = 2
        elif bok == 'D';
            index = 3
        elif bok == 'E';
            index = 4
        elif bok == 'F';
            index = 5
#
##   replace with
bok_dic = { "A":0, "B":1, "C":2, "D":3, "E":4, "F":5 }
if bok in bok_dic:
   index = bok_dic[bok]
else:
   index = -1

Finally, the following code uses the same value for "a" over and over. Instead, use two for() loops (adding 6 to the value of i). Post back if you can't get it and look at the first example I posted.

for i in range(0,5):
                    |-----this would be "i" = 0 --> 5
        matobj[0][a] = liobj[i]
        a = a + 1
    a = 0
    for i in range(6,11):
        matobj[1][a] = liobj[i]
        a = a + 1
    a = 0 
    for i in range(12,17):
        matobj[2][a] = liobj[i]
        a = a + 1
    a = 0
    for i in range(18,23):
        matobj[3][a] = liobj[i]
        a = a + 1
    a = 0
    for i in range(24,29):
        matobj[4][a] = liobj[i]
        a = a + 1
    a = 0
    for i in range(30,35):
        matobj[5][a] = liobj[i]
        a = a + 1
woooee 814 Nearly a Posting Maven

There is something in the README that comes with Python explaining how to install to a different path, but it would be simpler to install for your distro. Can you install software or do have to do it yourself because you don't have root? If you can install, then what distro are you using. Also you will probably have to add $HOME/local/lib and $HOME/local/bin to your path. You might try Active State's version. From the docs at http://docs.activestate.com/activepython/2.6/installnotes.html#aspackage
"To install interactively, simple run the install script without arguments. The install script will prompt you for an installation directory. On Unix: (Linux)
% tar xzf ActivePython-version.tar.gz
% cd ActivePython-version
% ./install.sh"

It also explains how to add the path so bash can find it.

woooee 814 Nearly a Posting Maven

Or, convert the zip to a list.

def swap(t):
    return t[1],t[0]

x=zip((1,3,1,3),("param","dorie","kayak","canoe"))

w=list(x)
print("w=", w)

y=sorted(w,key=swap)
print('y=',y)

z=sorted(w)
print('z=',z)

l=sorted(w,key=swap)
print('l=',l)
woooee 814 Nearly a Posting Maven

You have the right idea. To add it to your program, add another if statement to the smallest & largest calcs using your num %2==0 idea. This code is not tested.

else:
        if num > largest: #found new largest
            largest = num
            loc_largest = location
            
        if num < smallest: #found new smallest
            smallest = num
            loc_smallest = location]

        if num % 2 == 0:     ## even
            even_list.append(num)   # if you want a list of even numbers
            even_ctr += 1               # if you just want a total
        else:
            odd_list.append(num)    # list of odd numbers
            odd_ctr += 1                 # total

Also, initializing this way if fine
smallest = 124301293123
largest = 0
unless your largest number is less than zero. Another way to do it is to use the first number entered to initialize both fields, which is what will happen anyway as it will be larger than zero and less than 124301293123. That way, you don't have to guess how big to make "smallest" so it will be larger than the numbers entered, and vice versa for "largest".

woooee 814 Nearly a Posting Maven

semantically it feels more correct to give the first number in a list the location or position of 1 rather than 0

The first element of a list is the zero element because zero is the memory offset. To find an element, you go to the beginning of the block of memory and then go forward to the location of that element. So for the first element you go forward zero, for the second element you go forward one times the length, so if it is a 4 byte integer, then the second element would be at memory offset one times four, etc. You are perhaps coming from a word processor view point where there are lines of data in a document in a folder (where the first line is line #1). None of those things really exist. Programmers deal with streams/blocks of memory, but that is another topic. As programmers, we can either learn an existing language as someone else has written it, or write our own as we want it. Most of us are not capable of writing our own, so we learn and use what is already there.

woooee 814 Nearly a Posting Maven

I think you have something like 30 minutes to edit the post. After that it is toggled to off. I suppose to keep old posts from being edited endlessly.

woooee 814 Nearly a Posting Maven

The simpliest way would be using and IDE, like Idle, that has debugging built in.

woooee 814 Nearly a Posting Maven

Take a look as post #3 in the "starting python" topic at the top of the topics list on the Daniweb page. Basically, it would be

def function_name(catalog_f_name, write_filename):
    catalog_f=sextractor.open(catalog_f_name)
    catalog=catalog_f.readlines()
    sys.stdout=open(write_filename, 'w')
    for star in catalog:
       print star['X_IMAGE']
    sys.stdout=sys.__stdout__ 

## this calls the function with the appropriate names
function_name('Z2.cat', 'Z2X.txt')
woooee 814 Nearly a Posting Maven

The problem is that you never call the function avg.

while True:
    location = location + 1
    num = input("enter number ")
    if num == "done": #check for end of input
        print "the largest is ", largest
        print "at location ", loc_largest
        print "the smallest is ", smallest
        print "at location ", loc_smallest

        ## this will print "function avg", etc because that is what avg is 
        print "average is", avg
        ## this will execute the function
        print "average is", avg(list_name)

        sys.exit(0)

as paulthom said, you want a while loop that will get the numbers and append each number to a list (you don't keep them now so you have nothing to average). Do nothing else at input. When all the numbers have been entered, pass the list to the avg() function. Make one pass through the list getting the smallest and largest and adding each number to a total variable (but don't use the name "sum" as that is a reserved word). Then divide as you have already and return the smallest, largest, and average.

woooee 814 Nearly a Posting Maven

The standard deviation is The standard deviation is <function SD at 0x020EB630>

Don't use the same name for the function and the variable returned, hence "<function SD" at 0x020EB630>

woooee 814 Nearly a Posting Maven

I added print statements to Opacity() and nothing printed, meaning it never gets called. You might have to test for the location of the mouse cursor when the left button is pressed, or attach something to one particular widget. Sorry, I have never done anything like this so can't help much.

def Opacity(self):
     print "Opacity called"     
     while QMouseEvent(Qt.LeftButton):
          print "Opacity while"
          self.setWindowOpacity(0.5)
     else:
          print "Opacity else"
          pass
woooee 814 Nearly a Posting Maven

It looks like Nothing is used to declare a variable for use at a later time. Since you don't have to declare variables in Python, you should be able to just ignore it. If you want a variable to be persistent, then you will have to define it with some value. A snippet of the VB code would be helpful. It could then explain why someone is declaring a "non-variable" and what definition they assign to it later. Finally, think in terms of a solution, not a line by line translation of VB code.

woooee 814 Nearly a Posting Maven

Start with some code to read the file, as well as the file you want to write to. Also, how large is the input file? Hint, you will want probably want to use some kind of a container to hold the 3 items you want to write.

woooee 814 Nearly a Posting Maven

Generally, you would do a merge type program. Read in both files, compare and change, then write to a third file, which will be the merged file. So some pseudo-code

if "hb15b01" in record, find record in second file to change (let's say it has "hb15b00"), change "hb15b00" to "hb15b01" and write to the thiird file, then rinse and repeat.

It is not a good idea to try and replace directly into a file, because everything has to be exactly the same, and you can't guarantee that with any file. If you are replacing
2671, "hb1", " UGz9", 1,
with
"hb15b01"
a direct overlay could wind up with something like
2671, "hb15b01UGz9", 1,
because of the different lengths, which is not what you want. So you would generally use split() to isolate the field you want to change, modify it, and then use join() to convert back to a string.

Ene Uran commented: good point +6
woooee 814 Nearly a Posting Maven

What if I want to control how much my loop will increment by? For example:

for i in range (1, 30)
   if (apple == fruit)
        i = i + 6
   elif (grape == fruit)
        i = i + 2

Use a while loop with a variable defined outside the loop.

ctr = 0
while ctr < 30:
   if (apple == fruit)
        ctr += 6
   elif (grape == fruit)
        ctr += 2
   else ctr += 1   ## prevent endless loop
woooee 814 Nearly a Posting Maven

You should increment height, otherwise it's an infinite loop. In general you want to use a for() or while() loop and append to a list on each loop. Add print statements to print what you don't get (especially 'height' and 'start').

woooee 814 Nearly a Posting Maven

If you are using pack(), not grid, then you want side=LEFT. See this tutorial http://effbot.org/tkinterbook/pack.htm