15,185 Topics

Member Avatar for
Member Avatar for Klustor

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): …

Member Avatar for Klustor
0
537
Member Avatar for James0l9l

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 …

Member Avatar for TrustyTony
0
158
Member Avatar for Malinka

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 …

Member Avatar for TrustyTony
0
120
Member Avatar for scobie

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 …

Member Avatar for TrustyTony
0
333
Member Avatar for neocortex

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 …

Member Avatar for Neil Fraser
0
1K
Member Avatar for crsher

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 …

Member Avatar for TrustyTony
0
2K
Member Avatar for ChaosKnight11

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 …

Member Avatar for richieking
0
179
Member Avatar for Michael_Levin

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 - …

Member Avatar for TrustyTony
0
183
Member Avatar for HoneyBadger

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 …

Member Avatar for HoneyBadger
0
430
Member Avatar for TrustyTony

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.

Member Avatar for griswolf
3
2K
Member Avatar for Asset

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 :)

Member Avatar for Asset
0
706
Member Avatar for Teiji

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 …

Member Avatar for TrustyTony
0
363
Member Avatar for Nassarofficial

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 …

Member Avatar for griswolf
0
94
Member Avatar for Seagull One

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 …

Member Avatar for woooee
0
190
Member Avatar for TrustyTony

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 …

0
133
Member Avatar for j855

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) …

Member Avatar for TrustyTony
0
112
Member Avatar for KrazyKitsune

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 …

Member Avatar for KrazyKitsune
0
125
Member Avatar for masumar

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 …

Member Avatar for TrustyTony
0
428
Member Avatar for henryford

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 …

Member Avatar for griswolf
0
172
Member Avatar for br0wnm4n

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', …

Member Avatar for TrustyTony
0
118
Member Avatar for bambi231991

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 …

Member Avatar for TrustyTony
0
122
Member Avatar for sijei

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 …

Member Avatar for TrustyTony
0
123
Member Avatar for henryford

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 < …

Member Avatar for TrustyTony
0
125
Member Avatar for Chrisfs

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 …

Member Avatar for woooee
0
1K
Member Avatar for yeticannotski

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 …

Member Avatar for yeticannotski
0
82
Member Avatar for akkarin1313

[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 …

Member Avatar for woooee
0
2K
Member Avatar for novice20

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 ? :(

Member Avatar for npmaier
0
176
Member Avatar for bpross22

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 …

Member Avatar for woooee
0
210
Member Avatar for eldaerys

Howdo you delete a name from the local namespace and occurs as a free variable in a Nest block?

Member Avatar for richieking
0
55
Member Avatar for spacemanspiff92

[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 …

Member Avatar for richieking
0
116

The End.