15,185 Topics
| |
So what im trying to do is, if the user select his location then the listbox should be filled in with values. I always get [B]NameError: global name 'listcomputers' is not defined[/B] but i dont understand why. can anybody help me ? [CODE]import os import wx class MyForm(wx.Frame): def __init__(self): … | |
I am attempting to create code where the user can alter the A elements in the list continuously. If another letter in the list is replaced however, it should ask for new input from the user, and go back to the code where the user can alter A elements in … | |
Hello Everyone, I have a list of digits. What is the most efficient way to count the number of tokens between two known digits? Here is what I came up with: [CODE] def dis(l, a1, a2): i1 = l.index(a1) i2 = l.index(a2) distance = i2 - i1 - 1 return … | |
Hi Folks, I'm a noob but I'm slowly getting addicted to python. I've been hitting a wall for about 4 hours trying various things to no avail. It looks to me like it should work and runs without error but.... I expect the blockcount counter to be high (but it's … | |
| Hello! I wonder if anyone used google-diff-match-patch for fuzzy string comparisons, i.e., for finding a closest/most similar string? Can anyone explain and give some examples? Also, in genera, what would be the best matching algorithm in Python. I tried Levenshtein, but matches are not so good, and I tried difflib.get_close_matches … |
can anyone create a program for this? In this program, you will be creating a very simple pizza-ordering menu. At this pizzeria, there�s only one kind of pizza you can order: regular (cheese,) no toppings. Your choices are what size of pizza, and how many of them. You�ll need to … | |
So I made a few tutorial applications and understand the most basic Python concepts and I'm well on my way to become a Python addict, only one thing is standing between me and the road ahead. I'm trying to make my first "useful" Python application - a program that allows … | |
hello! can you please help me with fast numpy transform. i have qimage (argb32) converted to numpy, so it's now an array of shape (128,128,4). and i want the fastest way to convert it to grayscale - the formula is (pseudocode): [CODE]lerp(PIX, dot(PIX, (0.299, 0.587, 0.114)), alpha)[/CODE] where PIX - … | |
I am trying to add two hexadecimal numbers. [CODE]def addbinary(n1,n2): s = "" carry = '0' for i in range(3,-1,-1): if (n1[i] == '1' and n2[i] == '1' and carry == '0'): s = '0' + s carry = '1' elif (n1[i] == '1' and n2[i] == '1' and carry … | |
This handy function turns file into stream of words stripped of punctuation, whitespace and digits, but does not split for example we'd to two words. If you want that you can further process yielded words or change the definition. | |
def getAverage(numList): total = 0 for i in range(0, len(numList)): total = float(numList[i]) total = total + numList[i] average = total/len(numList) return average Hi, I'm really, really new to python, I'm having error on this function and I can't solve it yet, so can someone help? Thank-you :) | |
Hi, I was checking out the unittest module and try out the sample code. I save the code below in a file call "testrandom.py" and run it using IDLE (Python's default IDE), but I get the following in red. Obviously, the tests run fine as indicated by OK, but why … | |
The first one is: A program that searches within a file and by user input for a word, and counts how many of this word in the file, and if its in the file or not. Thats what i reached so far: sword, line= 0, 0 filename= raw_input("please input file … | |
I've been working hard all day to get this to work. I'm playing around with the math module in python. I eventually want the following code to help me control the speed of a servo motor. The idea is to get the servo speed to accelerate and then decelerate as … | |
I write usually many versions of the functions, sometimes writing functions from scratch again. Sometimes the parameters change from version to version, sometimes they are refering to library of functions that also has multiple versions. Has somebody advice on how to manage best this kind of situation? Should I define … | |
I have a question. I have a list of numbers like: Bobby 9 9 8 4 8 5 6 7 3 8 6 5 5 7 6 9 6 4 6 4 3 4 7 6 6 I have already written a code to take the numbers in range (1,15) … | |
I'm working on a self-project called 'Project Calculus' (Not that you care about the name). It's a huge calculator that works cross-platform and only uses 'already implemented' modules (So no SymPy, no NumPy, no SciPy, et cetera.) in it. I need help (If you even bother to cooperate with a … | |
Hi, How do I sum all occurrences of a number in a file? I have a file with a bunch of numbers, each on it's own line: 5 3 11 3 7 3 5 5 11 7 7 ... How do i sum them up so that the output will … | |
Hey guys and gals I am really struggling with this program. I have been working on it for about a week now and every time I think I am getting somewhere it seems like it flops and I get frustrated and start over. I would appreciate it if anyone could … | |
def scary(filename): infile = open(filename, 'r') content = infile.read() infile.close() for i in ';",.()[]{}\/0123456789@#!$': content = content.replace(i, ' ') words = content.split() d = {} for word in words: if word in d: continue else: d[words] = words lst = [] for n in d: lst.append(n) lst.sort() outfile = open('dictionary.txt', … | |
I need to know if i can take a user inputed string such as [code=python]name = raw_input("Enter Name:")[/code] and take the word inputed and break the string apart by letters for example: If the user enters "joe" i will get "j", "o", "e" is this possible? also i need to … | |
Im a beginner programmer this semester, and python is my first language. I can do the homework but am naturally curious at spiffing up my programs to help me understand how to have many things working at once in a program. I have some ideas but have not been able … | |
I keep getting a error for adding strings and integers together. how can I fix this? It is in the line hours.append(hWork + "\n") [CODE] hours=[] hWork="1" while True: employee=raw_input("\nPlease enter the employees' first and last name. ") hWork=int(raw_input("How many hours did they work this week? ")) if hWork < … | |
Hi, I keep getting the error Traceback (most recent call last): File "<string>", line 11, in <fragment> builtins.TabError: inconsistent use of tabs and spaces in indentation (<wingdb_compile>, line 11) With the lines being [CODE] for line in datafile: pricedata = line.split(",") newdata[pricedata[0]] = pricedata[6][/CODE] I have taken out and put … | |
Dear All, I am not only new to python, but completely new to programming in general. So please don't laugh (too much) of this certainly dumb question. I was going through the first pages of "A Byte of Python" and decided to change a bit one of the models and … | |
[code]def main(): splash() wordTotal = 0 longestWord = 0 fin = open("constitu.txt") for line in fin: #n = fin.readline() wordLine = line.split() #word = wordLine.split() wordTotal += len(wordLine) #if len(word) >= 15: #longestWord += 1 #print word print "This constitution has ",wordTotal, " words." def splash(): print "This program is … | |
I have python 2.5.2 on my Debian system n want to upgrade it to python 2.6. Got to know that apt-get install package searches for package in /etc/apt/sources.list I have downloaded python 2.6.2. How to add an entry to the file /etc/apt/sources.list ? :( | |
Hi everyone, I am trying to create a list of objects in python. I get the listing of all of the files from the directory that I want. Then I open each file and read it into an appropriate object and append it to the list. For some reason when … | |
Howdo you delete a name from the local namespace and occurs as a free variable in a Nest block? | |
[CODE]def exportTextList(fileInput, wordList): fileOpen = open(fileInput) for line in fileOpen: line = line.rstrip("\n\r") lineList = line.split() wordList = wordList + lineList return wordList def main(): fileInput = 'PlayerNames.txt' wordList=[] exportTextList(fileInput, wordList) print wordList[/CODE] My code summary: I'm taking a txt file, playernames, and i'm stripping all of the line breaks … |
The End.