woooee 814 Nearly a Posting Maven

We posted at the same time. Here is http://packages.ubuntu.com/dapper/python2.4-imaging-tk You wil probably have to click the download link on the far right and install using dpkg. And then you can use "search" at the top of the page for the rest. Try to get the package for the specific disto you are using or as close as possible. I use Slackware so am not sure, but it's something like "dpkg -i package-name" installs. Check man dpkg for details. Again, if it does not install into /usr/lib/python2.4/site-packages then simlink it Also, asking here is a good idea, but the Ubuntu forums are usually very good also for something Ubuntu specific.

Just wanted to see if they were available,
Tkinter should already be in /usr/lib/python2.4/lib and readline is not python specific
http://packages.ubuntu.com/search?searchon=names&keywords=numeric+2.4
http://packages.ubuntu.com/search?suite=default&section=all&arch=any&searchon=names&keywords=python+imaging+2.4
http://packages.ubuntu.com/search?suite=default&section=all&arch=any&searchon=names&keywords=pmw
http://packages.ubuntu.com/search?suite=default&section=all&arch=any&searchon=names&keywords=python+opengl
So clicking on dapper for Pmw says that it requires python 2.4, so you probably want packages built for that distro http://packages.ubuntu.com/dapper/python-pmw

woooee 814 Nearly a Posting Maven

I'm doing a project doing atomic models and am using a toolkit that was developed for Python 2.4 on Ubuntu

That toolkit should run under 2.6 even though it was developed using 2.4, so your first option is to try running it using 2.6. /usr/bin/python should point to python2.6 somewhere on the system (where depends on how it was configured).

If that doesn't work then you want to symlink the necessary libraries from/usr/lib/python(2.6)/site-packages to /usr/lib/python2.4/site-packages since they were obviously installed into the 2.6 libraries. They should work even though they were compiled against 2.6. The shebang in the toolkit would then be "#!/usr/bin/python2.4" or whatever. Alternatively you can run it with "/usr/bin/python2.4 toolkit.py".

If that doesn't work, then you will have to install each of these packages and make sure they are in, or symlinked to /usr/lib/python2.4/site-packages. Installing should be simple since they are mostly python scripts, but I'm not sure about all of them

woooee 814 Nearly a Posting Maven

You read it one line at a time, but write only if the counter is between the numbers. And don't use "i", "l", or "o" as single variables because they look too much like numbers.

f = open(infile,'r')
o = open(outfile,'w')
ctr = 1

for line in f:
   if first <= ctr <= last:
      o.write(str(ctr)+'\t'+line)
   ctr += 1

f.close()
o.close()
woooee 814 Nearly a Posting Maven

Running the following code yields the result posted. id is one of the first things you want to know when two objects appear to be the same.

f = FD_field(4, 4, 4)
f.At(1, 1, 1)
print ("f #1 id = %d" % id(f.data))

f.Set(1, 1, 1, 5)
f.At(1, 1, 1)
print ("f #2 id = %d" % id(f.data))

g = FD_field(4, 4, 4)
g.At(1, 1, 1)
print ("g #1 id = %d" % id(g.data))

This prints
f #1 id = 3083171468
f #2 id = 3083171468
g #1 id = 3083171468
Note they all have the same id, and so are the same object. First avoid globals, such as the ones at the beginning of your class. Second, add a unique self.data for each instance. Running the code below should result in what you want.

class FD_field:
    """Finite-difference Maxwell Solver Field Data-type"""
    # Data declarations and initialization
    lenx = 0
    leny = 0
    lenz = 0
    data = []
    #
    # --- Class __init__ declarations ---
    #
    def __init__(self, jj, ll, nn):
        self.lenx = jj
        self.leny = ll
        self.lenz = nn

        ##---  added a unique self.data field for each instance
        self.data = []

        l = []
        for i in range(self.lenx):
            dl = []
            for j in range(self.leny):
                dm = []
                for k in range(self.lenz):
                    dm.append(0)
                dl.append(dm)
            self.data.append(dl)
        del dl, dm, l, jj, ll, nn, i, j, k
    #
## The rest of the code remains the same

The id's print
f #1 id = 3083034188
f #2 id = 3083034188
g #1 id = 3082646892 <----- different

woooee 814 Nearly a Posting Maven

One of you should have just written the entire program in the beginning, since the OP didn't have to produce even one line of original code, and saved everyone the trouble of having to read through all of the posts.

woooee 814 Nearly a Posting Maven

def __init__(self, name):
self.__monName = name

monFile.write(self.__monName)

Somehow you are passing a tuple to the class. How do you call the class and what name are you entering? Also, add a print statement before the write
print type(self__monName), self.__monName
monFile.write(self.__monName)

woooee 814 Nearly a Posting Maven

which prodcues

*element,type=s4r,elset=WSLAB
100001,6,4719,6308
,12
*element,type=s4r,elset=WSLAB
100002,4719,2328,2327
,6308

It appears that you have a newline in with the final element of the list, so after the exchange, the next to the last element prints the newline which puts the last element on the next line. You should .strip() before appending to the list which will get rid of the newline.

woooee 814 Nearly a Posting Maven

You can download an Ubuntu live CD from here (are there are a lot of tutorials on how to put it on a USB drive), but Knoppix is better IMHO because they have tools like GParted for repairing the system. https://help.ubuntu.com/community/LiveCD Also, there is a netbook version if you don't already know https://wiki.ubuntu.com/UNR

woooee 814 Nearly a Posting Maven
i_getdata_test = [ \
(30, 0, 0), \
(29, 0, 0), \
(28, 0, 0), \
(27, 0, 0), \
(26, 0, 0), \
(25, 0, 0), \
(24, 0, 6), \
(23, 0, 0), \
(22, 0, 0), \
(21, 0, 0) ]

for pixel in i_getdata_test:
   print pixel
   ##  0, 1, and 2 are the memory offsets for
   ##  the three integers in the tuple
   if pixel[2] > 0:
      print "          we want this one"
    
## if you want to explore what the "2" means,
## then uncomment the lines below
##print "\n"
##for pixel in i_getdata_test:
##   print pixel[0], "-->", pixel[1], "-->", pixel[2]
woooee 814 Nearly a Posting Maven

os.system("cd \..\Program Files\Mozilla Firefox\ Start firefox.exe")

"cd" = change directiory. You want to execute the program which you should be able to do by calling it from os.system()
os.system("\..\Program Files\Mozilla Firefox\ Start firefox.exe")
Check this directory to make sure you want to call "Start firefox.exe" instead of "firefox.exe" or "/Start/firefox.exe". I'm not familiar with MS windows but the file has to exist in order to call it. os.system is the same as clicking on the file, so you want whatever name you would click on.

But you should get used to using subprocess instead of os.system as it is the preferred way.
subprocess.call(["\..\Program Files\Mozilla Firefox\ Start firefox.exe"], shell=True)
You can find info about os.system and subprocess here http://www.doughellmann.com/PyMOTW/modindex.html

woooee 814 Nearly a Posting Maven

Print dirList1 and dirList2 at the beginning of the function, or at least the length of each. The first step is to make sure that both contain what you think they contain.

woooee 814 Nearly a Posting Maven

Assuming that sum_results is a dictionary that contains numbers of decimal class, you can use

total_cost = float(sum_results['list_price']) + salestax + shipping_cost + rush_cost

If this doesn't work, then print the type for each variable
print type(sum_results) etc.
You can check the docs for the decimal class at python.org if you want to know more about it.

woooee 814 Nearly a Posting Maven

Your existing code looks like it wants to find records where the field "month" equals myprice. The field "sql" is just a string so you format it like any other string. Post back if this isn't enough to get it to work.

##   assuming month, myprice and mytel are integers
    sql = 'UPDATE mydatabase SET %d = %d WHERE number = %d' % \
                                  (month, myprice, mytel)
    print sql
    cursor.execute( sql )
    connection.commit()
woooee 814 Nearly a Posting Maven

1. Sort the list and test for this_number == next_number and add one to a counter if a duplicate.
2. Use a dictionary (if you are familiar with dictionaries) with the number as key pointing to a counter. Increment the counter every time that number is found.

woooee 814 Nearly a Posting Maven

I like using sets because they have a difference function.

alphabet = set("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
keyword = raw_input("Enter word ").upper()
difference = alphabet.difference(keyword)

## sets are in hash order not in alphabetical order
print "Hash sequence", difference, "\n"

## convert to a list so it can be sorted
difference = list(difference)    
difference.sort()

## now it is in alphabetical order
print "Alpha order", difference, "\n"

## create a new list with the keyword first
final_list = list(keyword) + difference
print "Final_list", final_list
woooee 814 Nearly a Posting Maven

First, make sure that all repositories are enabled, and that you update after that. If you have Gnome Ubuntu and you want to install a KDE package for example, the default repos will not find KDE apps because those repos are not enabled.

woooee 814 Nearly a Posting Maven

the error is coming up at r squared minus y squared

That would be two calculations, not one, so you have to break that down and see which one is causing the error message. If this doesn't give an error message
r_squared = r*r
y_squared = y*y
sqrt_2 = math.sqrt(2)
sub_total = r_squared - y_squared
etc. (insert the rest of the equation on the lines that follow)
Then why would the one-liner show an error, and why that particular message and what does the error message mean?
l = abs(math.sqrt(2)(r*r)-(y*y))

woooee 814 Nearly a Posting Maven

Hopefully your teacher did not give a passing one.

That was a joke BTW. It's an easy mistake to make.

woooee 814 Nearly a Posting Maven

l = abs(math.sqrt(2)(r*r)-(y*y))
Break this formula down into one calc per line and see where the error occurs, then print the variable and it's type(variable_name), and that should tell you where you went wrong. Also, it is not polite to use "i", "l",. or "o" as single letter variable names. They look like numbers and can be confusing to someone trying to decipher someone else's code.

woooee 814 Nearly a Posting Maven

Once the user gives the program these parameters I would like to put it into the file below on line 11 and re save it as Compare # 2.asc.

Apparently he does want to change the file posted, but since every tutorial covers file read/write, and no effort has been made by the OP to produce any code, -1 to the "write the program for me" posts.

woooee 814 Nearly a Posting Maven

Hey I did this in class the other week. This code is simple and works perfectly

import random
Num = int(raw_input("enter number of coin flips:"))

coinf = 0
h = 0
t = 0

while coinf < Num:
    coinf = coinf + 1
    rand = random.randint(0,2)
    if rand == 1:
        h = h + 1
    else:
        t = t + 1
print h, "heads",t, "tails"

What kind of a grade did you get. Hopefully your teacher did not give a passing one. Run this modified version and see if you can tell why you will always get approximately twice as many tails as heads.

import random
Num = int(raw_input("enter number of coin flips:"))

flips_dic = {}
coinf = 0
h = 0
t = 0

while coinf < Num:
    coinf = coinf + 1
    rand = random.randint(0,2)
    if rand not in flips_dic:
       flips_dic[rand] = 0
    flips_dic[rand] += 1
    if rand == 1:
        h = h + 1
    else:
        t = t + 1
print h, "heads",t, "tails"
print flips_dic
woooee 814 Nearly a Posting Maven

I don't remember if SQLite is installed by default or not. A test is of course
import sqlite3
Even though you may not use it, there are various apps that do. Also, check out the programming forum there http://ubuntuforums.org/forumdisplay.php?f=39

woooee 814 Nearly a Posting Maven

# changes the system's current dir. path to specified path

It doesn't change the path, it adds that path to the list that Python searches. You can print sys.path if you want to see what it is.
sys.path.append("/engine/lib/") ## or whatever it is
import sprite_class
and then
sprite_obj = sprite_class.Sprite()
to call a function in the class Sprite, use
sprite_obj.function_name(vars)
to access a variable
print sprite_obj.starting_y
Note that the function CD does not return anything so sprite_obj will be destroyed when you exit the function.

woooee 814 Nearly a Posting Maven

You should not be using "is" for comparison. It is used to test if the objects are the same. Guido, et al decided to store an internal list of 1-256 and reference the list for those numbers, so if you try:
x=257
print x is 257
it will print False because they are different objects.

#if n is not 0:
        ## use
        if n:     ## if n != 0: will also work

            #if a % n is 0:
            if a %n != 0:
woooee 814 Nearly a Posting Maven

effbot has some nice ultra noob stuff for the beginner. See here (and you might want to check out the rest of their tutorial and then continue on with whatever on you have now) http://effbot.org/pyfaq/how-do-i-run-a-python-program-under-windows.htm

Edit: I just realized that this tutorial is for version 2.5 and lower, so it may throw some curves for someone who isn't familiar with the differences. You probably want to stick with the 3.0 tutorial that you have. Also, if you use Idle, which should have been installed along with Python, you can save and run the program from Idle, and it makes learning a lot easier IMHO. It should be under the Start-->Programs-->Python menu (or something similiar). A slightly old tutorial for Idle http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html

woooee 814 Nearly a Posting Maven

2. In order to get to condition 2,the values of "x", "y", and "z" must all be the same.

Double check this. With my limited tests, it appears that if x == y, it doesn't matter what z is (or y == z and the value of x doesn't matter), which would mean that condition 3 would start with x != y to get by condition 2, and then additional constraints to get by condition 1. I doubt that there is only one set of numbers (which is what you have) to get to condition 3.

woooee 814 Nearly a Posting Maven

To start with, what do these mean and what is the order of their evaluation? Post your answer here if you want some help.

if (y>x and y<z)or(y<x and y>z):
   elif not(x!=y and y!=z):

Since you have code, you can answer the first question by brute force. Set x and y to 10, and then loop through increasing values of z to see where you get a response from the third condition. __And Then Figure Out Why.__ After that you should be able to answer question 2.

Edit: Note that an "and" is two if() statements, and an "or" is an if() + elif(). So if it is easier to understand you can rewrite it.

if (y>x and y<z)
## becomes
if y > x:
   if y < z:
      print("You have entered Condition 1 because y > x AND y < Z")
##--- now for the "or"
elif y < x:    ## etc
woooee 814 Nearly a Posting Maven

Upon initial inspection I see that you're opening PAY.txt as salariesWage and then employeeWage but then trying to read/write as salariesList and employeeList respectively. That should fix your reading/writing problem...

Also, that block of code should go under the while loop as well in order to write each employee. Hopefully, the reason for this is obvious. So you will have a while loop, it will do everything until "Done" is entered, which will trigger a break() statement, and then you can print something like "Bye bye" if you want to show that you have exited the loop.

woooee 814 Nearly a Posting Maven

I can loop through all three questions ONE time and that's it.

while hours<1 or hours>60:
            hours=int(raw_input("Enter the number of hours

If you entered 42 hours on the first pass, then hours still equals 42 and you will not enter the while loop. See Shibby's snippet. Use one infinite while() loop, to get all of the data, and break out of the loop when "Done" is entered.

woooee 814 Nearly a Posting Maven

Tkinter is just a wrapper around TCL/Tk, which is also a scripting language, so it defines it's own variables. So
self.t_name = StringVar()
declares the variable self.t_name as a TCL/Tk string
text = Entry(frame_e, textvariable=self.t_name, bg="white")
says that name of the variable containing the text/data, for the widget named text, is "self.t_name".
self.name = self.t_name.get()
converts a Tk string variable to a python string variable.
Here are links that between them answer pretty much any question that a normal user might have.
## Control Variables at N.M. Tech
http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html

## Fredrik Lundh's page (effbot.org)
http://www.pythonware.com/library/tkinter/introduction/index.htm

## New Mexico Tech
http://infohost.nmt.edu/tcc/help/pubs/tkinter/

woooee 814 Nearly a Posting Maven

You want to use a class. The variable will be visible and accessible as long as the class exists.

from Tkinter import *

class Demo:
   def __init__(self, top):
      self.name=""
      frame_e = Frame(top)
      frame_e.pack()
      self.t_name = StringVar()

      text = Entry(frame_e, textvariable=self.t_name, bg="white")
      text.pack()
      text.focus_force()

      nameButton = Button(frame_e, text="Accept", command=self.Naming)
      nameButton.pack(side=BOTTOM, anchor=S)


   def Naming(self):
      self.name = self.t_name.get()
      print self.name
      root.destroy()

root = Tk()
root.geometry=("100x100+100+50")

D=Demo(root)

root.mainloop()

print "name retrieved was", D.name
woooee 814 Nearly a Posting Maven

It seems that all you have done is to copy code you found somewhere else. For example, what does this line that you posted mean and why would it be used in a fib sequence?
a, b = b, a + b
Start with a routine to get the number(s) to begin with and the number of fibs that you want, or the maximum value you don't want to exceed before stopping. Post the code here. Then write some code to calculate one fib number in a sequence, given the previous sequence. Because a fib can start with any number(s), you first have to set the parameters and then calculate the fibs.

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

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

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

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

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

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

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

You can use a while loop, something along the lines of

found = 0
while not found:
    print "Please use W or L to input the results of the game"
    print
    win_loss_code = raw_input('Enter W for Win or L for Loss: ')
    win_loss_code = win_loss_code.lower()
    if win_loss_code == "w":
        print "You won"
        found = 1
    elif win_loss_code == 'l':
        print "you lost"
        found = 1
    else:
        print "Error"
        print 'Please use only "W" or "L" '
##---------------------------------------------------------------------
## if you have a lot of letters to test, use a dictionary
print_dic = {"w":"You won", "l":"You lost", \
                    "x":"Stupid, no one uses x" }
found = 0
while not found:
    print "Please use W or L to input the results of the game"
    print
    win_loss_code = raw_input('Enter W for Win or L for Loss: ')
    win_loss_code = win_loss_code.lower()
    if win_loss_code in print_dic:
        print print_dic[win_loss_code]
        found = 1
    else:
        print "Error"
        print 'Please use only "W" or "L" '

There are a lot of variations on this, including the use of a function for input, but this is the general idea.

woooee 814 Nearly a Posting Maven

To delete from a dictionary, use
del dict_name[key]
so I think you would want
del records[entry]
but you will have to test that for yourself. You really should learn to Google as this is simple so examples abound on the net. See here http://www.diveintopython.org/getting_to_know_python/dictionaries.html

woooee 814 Nearly a Posting Maven

if entry in records:
should work. You then replace the "r" in the print statements with "entry".

woooee 814 Nearly a Posting Maven

A slight modification.

for index, item in enumerate(arr):
    if item > 100:
        return index, item

See here for info on lists http://effbot.org/zone/python-list.htm

Edit: Damn, this is probably homework. My mistake. Using enumerate will probably red flag it though.

woooee 814 Nearly a Posting Maven

The program that I submitted works fine, with "?", on Python 2.5. Take a look at it. If you still can't get your program to run, then submit the code you are now using as it has changed from the first post.

woooee 814 Nearly a Posting Maven

rcw is a list of lists. You want to write strings to a file so you have to add one more level.

for record in rcw:
   bird = record.strip().split()
   ##   add this to each record
   outgroup.write("%s" % (dID[bird[3]])   ## assuming this is a string

   ##   bird is a list
   for field in bird:
      outgroup.write(",  %s" % (field))   ## you may not want the 
comma
   outgroup.write("\n")
##
##   or more simply
for record in rcw:
   bird = record.strip().split()
   ##   prepend this to each record
   outgroup.write("%s  " % (dID[bird[3]]))
   ##  and the record
   outgroup.write("%s" % (record))   ## assumes record already has a "\n"
woooee 814 Nearly a Posting Maven

You also want a conn.comit() after inserting. And you should take advantage of using a class, plus change the first statement to use python.

#!/usr/bin/python
# SQLite command to be used with the applications
import sqlite3 as sqlite

class SqliteCommands:
    def ___init__(self, parent):
        self.parent = parent

    def list_all_recs( self, t_name ) :
        self.cur.execute("select * from %s" % (t_name))
        recs_list = self.cur.fetchall()
        for rec in recs_list:
           print rec

    # Create database
    def onCreateDb(self, t_name):

        self.conn = sqlite.connect("%s" % (t_name))
        self.cur = self.conn.cursor()
##        return (conn, cur)     ## not necessary

    #Create New Table
    def onCreateTable(self, t_name):        
       SQL_str="CREATE TABLE IF NOT EXISTS %s" %(t_name)
       SQL_str += "(Date TEXT, Explanations TEXT, Deposit REAL, "
       SQL_str += "Withdraw REAL, Balance REAL)"
       self.cur.execute(SQL_str)

    #Create Rows for the New table    
    def onInsertRows(self, t_name, tuple_rows):
        SQL_str ="INSERT INTO %s VALUES(?, ?, ?, ?, ? )" % (t_name)
        self.cur.execute(SQL_str, tuple_rows)         
        self.conn.commit()        


x = SqliteCommands()
x.onCreateDb("Steve")
x.onCreateTable("Steve")
t = ("03/02/2009", "Billing for electricity", 200.0, 230.0, 270.0)
x.onInsertRows("Steve", t)
t = ("03/02/2009", "Billing for gas", 100.0, 210.0, 200.0)
x.onInsertRows("Steve", t)
x.list_all_recs("Steve")

Maybe you should write a simpler test program first

This is good advice. First, test onCreateDb to see that it is working, then test onCreateTable, etc. When the program doesn't run at all there is something wrong with the shebang (#!/usr/bin/python).

woooee 814 Nearly a Posting Maven

"records" should be a dictionary (code has not been tested)

# A list of entries
# Each element will be a dictionary
records = {}
next_number=1

# User input
user = ""
while user!="0":
    #display menu
    print
    print "  Film Database"
    print "-----------------"
    print "1 -- Add Entry"
    print "2 -- List Entries"
    print "3 -- List Single Entry"
    print "4 -- Delete Single Entry"
    print "0 -- Exit"
    print "-----------------"
    print len(records), "entries."
    print
    print "Enter option:",

    #Get user input
    user=raw_input()

    if user=="1":
        #Add to database

        #create empty dictionary
        item={}
        
        print "Enter title:"
        item["Title"]=raw_input()
        print "Enter director:",
        item["Director"]=raw_input()
        print "Enter year:"
        item["Year"]=raw_input()
        records[next_number] = item
        next_number += 1
    elif user=="2":
        #display database
        print '-'*10
        for r in records:
            print "record number", r
            print "Title:   ",records[r]["Title"]
            print "Year:    ",records[r]["Year"]
            print "Director:",records[r]["Director"]
            print "-"*10
            print
            ##--------------------------------------------
            ## which is the same as
            #this_item = records[r]
            #print "Title:   ",this_item["Title"]
            #print "Year:    ",this_item["Year"]
            #print "Director:",this_item["Director"]
    elif user=="3":
        #ask for which entry to view
        print "-"*10
        entry = int(raw_input('entry: '))
        

    else:
        print "Unknown option"

This would work much better using an SQLite database.

woooee 814 Nearly a Posting Maven

if you want to make a super amazingly quick program and it had to be in python then maybe this could even matter (i doubt it)

I doubt it as well. I view the "function calls are expensive" as someone trying to impress with how much they know. Function calls are expensive, AFAIK, because the function is in a different block of memory, so the program has to go to that block, execute it, and then come back to where it was. I care a __lot__ more about readability and being able to understand something that was written long before my little gray cells' memory of it. A function separates things nicely. If it takes an extra milli-second or two, fine.