i have an html form with a drop-down list that lists a bunch of images. how can i get my cgi script to load the image ? i have imported cgi and os text entered from a form and read from a file do ok, but i cant seem to get it to load an image. the form writes all of the entries as lines in a .txt file this file is selected later, all the lines are read, and based on the first line of the text file determines the name of the .gif image to load. is there …

Member Avatar
Member Avatar
+0 forum 7

hey there, i have written a script that gets my email messages, but i need to be able to strip off all of the stuff except the body of the message so i can write that to a text file. is there an easy way to do this ? Edit/Delete Message

Member Avatar
Member Avatar
+0 forum 8

I do not understand why the instructions are being printed off of the margin(about 5 spaces). I would think they would be directly on the margin. I am talking about this part in particular [quote] you first need to choose to go first or second. If you choose to go first you will be X's. If you choose to go second you will be O's. you will choose your 'move' on the board by using the following key.[/quote] [php] # print_board.py # # this function prints the board, it takes # its parameter in the form of a list, the …

Member Avatar
Member Avatar
+0 forum 2

I am getting really tired, so I am probably doing something dumb(disclaimer). below is a python function I am trying to test [php] # answer.py # # this function asks for a move and checks to see # if it is a legal place to choose. position = ['X','O',' ',' ',' ',' ',' ',' ',' '] # this line is for testing only def answer(): guess = int(raw_input("please enter your move(enter here)")) while guess - 1 not in range(9): guess = int(raw_input("please enter a number chosen from 1-9(enter here)")) while True: if position[guess -1] in ('X', 'O'): guess = int(raw_input("\nplease …

Member Avatar
Member Avatar
+0 forum 1

Hello, Now that I have been instructed as to how to write unicode characters in Python, I would like to know if it is possible to get the unicode characters into a list, dictionary, etc. Here is my very simple code: [code]a = u'\u05e9\u05dc\u05d5\u05dd!' print a print print mylist = ["qwerty","uiop",a] print mylist [/code] The result I get is: [code]שלו

Member Avatar
Member Avatar
+0 forum 2

Hi all, I am trying to learn unicode relative to Python, but to be honest, I'm floundering a whole lot. I have never had so much trouble with anything before, but to put it simply, I just don't get it. For example, I want to use Hebrew words in my Python program. But no matter what I do, I get the error about unsupported characters. So is there anything I can do to get Python to support those characters? Please keep it simple, 'cause my brain isn't up to it. Thanks Iacobus

Member Avatar
Member Avatar
+0 forum 5

from my understanding, a list can do everything a tuple can do plus more. The big advantage of using a list is you can change elements, lists are mutable. Are their situations where a tuple is preferable to a list?

Member Avatar
Member Avatar
+0 forum 1

I am trying to follow this code I am reading in a book. First I will show you the code as the book has it. This is for a word jumble program. This algorythm I am refering to jumbles a word [php] import random # create a sequence of words to choose from WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone") # pick one word randomly from the sequence word = random.choice(WORDS) # create a variable to use later to see if the guess is correct correct = word # create a jumbled version of the word jumble ="" while …

Member Avatar
Member Avatar
+0 forum 3

Hi everyone. This is my first post in the python thread and I am very new to the language. A while ago, i wrote a program that find the least common denominator for an array of numbers in Java. I recently started to look at the python language and I have attempted to write the same program in python. I wrote it and it works up to just one part. I have a 'while' loop with an inner 'for' loop. inside the for loop it has an 'if' statement that has a result of a 'break'. From what I have …

Member Avatar
Member Avatar
+0 forum 7

Hey there, i have a python cgi script that prints out html just fine in the Opera browser but doesnt print at all under FireFox. weird, eh? i am getting nothing in the apache logs about any error. perhaps its a firefox issue, but i doubt it. any suggestions. simple script here..

Member Avatar
Member Avatar
+0 forum 1

here below is my code [code] #!/usr/bin/python #this is my third python script print \ """ this is a python program to figure out total sales price, including tax\n\n \t\t\tprogrammed by\n \t\t\tShane Lindberg\n\n """ base_price=int(raw_input("please enter the base price of the car:\n$")) under_coat=int(1000) stereo=int(200) air=int(750) tax=int(base_price*.07) print "the total price of the car with all extras and tax is: $",base_price+under_coat+stereo+air+tax[/code] this statement is not behaving in the way I think it would [code]print "the total price of the car with all extras and tax is: $",base_price+under_coat+stereo+air+tax[/code] why is it adding a space after the "$" character like below [code]please enter …

Member Avatar
Member Avatar
+0 forum 2

Hey there. Here is the deal.... i have a script that is supposed to open a file based on criteria from a web form. i cant seem to get it to work though. here is the code: [CODE]form = cgi.FieldStorage() DataRecord = form['DataTime'].value Customer = form['CustName'].value # should be automatically filled in print "Content-Type: text/html\n\n" print WorkingFile = open("/var/www/stretch/web_root/SidCrops/"+Customer+"/"+DataRecord, "r") all_lines = WorkingFile.readlines() WorkingFile.close() for line in all_lines: print line[/CODE] here is the error: WorkingFile undefined, builtin open = <type 'file'>, Customer = 'tenderloin', DataRecord = 'Tue Jun 7 20:13:35 2005.txt' IOError: [Errno 2] No such file or directory: '/var/www/stretch/web_root/SidCrops/tenderloin/Tue …

Member Avatar
Member Avatar
+0 forum 5

I was wondering if anyone knew of a good text editor for python ?

Member Avatar
Member Avatar
+0 forum 3

Hi, I am a Java programmer dabbling in Python for the first time. Mostly, the transition has been pretty smooth, but this week something stumped me. Please forgive me if the answer to this is completely obvious - I've read van Rossum's tutorial and can't figure it out. I am working on a Python project composed of one main module and several smaller helper modules. Each module is currently in its own file, which (I believe) is the convention Python uses. The main module is called MainProgram.py and one of the helper modules is called Helper.py. MainProgram.py has to import …

Member Avatar
Member Avatar
+0 forum 3

Hey there, i am trying to write an online application using the cgi module. what i want to do is have an html form display a drop-down list and have the values of that list be the lines of text written in a file. this would be updated almost every time the site is visited. i have been sucessful in writing text to a file from an html form. but i need to access this so it can be selected. is there a way to do this? i have found limited info on how to really use the cgi module. …

Member Avatar
Member Avatar
+0 forum 2

I am new to pragramming and also Python. I was reading the intro and basics for beginners in the sticky of this forum and tired it out. It was cool and all but after saving the files, I click F5 to run it and i get the error message : Syntax Error There's and error in your program: invalid syntax then in highlights in orange the number "4" of 2.4.1 in the top of the IDLE thingy that shows the version "Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" …

Member Avatar
Member Avatar
+0 forum 7

Hey there, i need some help with a simple cgi script. i cannot get it to write output to a file. here is the script. [CODE] #!/usr/bin/python import cgi form = cgi.FieldStorage() Customer = form['Customer'].value Field = form['Field'].value data = [Customer, Field] reshtml = """Content-Type: text/html\n <html> <head><title>Customer Data</title></head> <body> <h1>Customer Data</h1> <p>Here ya go</p> </body> </html>""" print reshtml + 'Customer =' + data[0] print ' ' + ' Field = ' + data[1] # this is where the script fails to do anything.... OutFile = open("/home/nephish/Test.txt", "w") OutFile.write("Here is a spot of text to input") OutFile.close [/CODE] it works, …

Member Avatar
Member Avatar
+0 forum 3

HEY EVERYONE THERE I WUD LIKE U TO TELL THT FUTURE IS "python" everythin is "python" atleast 4 those who hates writin in creepin c,c++ programmin languare which is error prone

Member Avatar
Member Avatar
+0 forum 2

what program is this ?

Member Avatar
Member Avatar
+0 forum 2

Hi, I have the following interface for a 35 day month calander script that I am writing. The interface is called for use with an html page. I am supposed to collect user input which includes day, month and their event. blankEventsJan = [ ['<br>','<br>','<br>','<br>','<br>','<br>','<br>'], ['<br>','<br>','<br>','<br>','<br>','<br>','<br>'], ['<br>','<br>','<br>','<br>','<br>','<br>','<br>'], ['<br>','<br>','<br>','<br>','<br>','<br>','<br>'], ['<br>','<br>','<br>','<br>','<br>','<br>','<br>'] ] I have already collected user input to tell me what day, month and event is required. Now I need a way to insert the user info into the correct month and return the month in the same interface forum as above. I have tried to create a new file which …

Member Avatar
Member Avatar
+0 forum 12

I have a program due and I cannot figure it out! I have read about 30 tutorials to no avail! I need to have data read into python from an input file. The data is suppossed to be info from a pretend university that only has 10 students. Once I figure out how to input the data I should be able to do the rest but right now I am stumped!

Member Avatar
Member Avatar
+0 forum 14

Hi I am trying my first try at Python. I want to do something very similar to what sprintf does with C. I want to concatenate a string with a number and store it into a new string. I wrote a snippet like this username='user' for i in range (1-100) user=user_name+str(i) print user else: print 'The loop is done' But this one fails to do the same. Can somene help me decipher where exactly I am going wrong. Thanks for your help regards Ram

Member Avatar
Member Avatar
+0 forum 3

some one recomended i learned python too, wwhat it is??

Member Avatar
Member Avatar
+0 forum 2

The End.