15,194 Topics

Member Avatar for
Member Avatar for WolfShield

Hello everyone, I was wondering, if I wanted to make my code a little smaller in one file, is it possible for me to import another file I made? E.G. (Very simple e.g. just for helping understand what I mean) Let's say I made a program that the user types …

Member Avatar for TrustyTony
0
1K
Member Avatar for mbartz

I am trying to Subclass ElementTree with an abstract method. I have read in several forums that ElementTree is actually both a module and a class. I have been unable to get the subclassing to work. [CODE]from abc import ABCMeta, abstractmethod from xml.etree.ElementTree import ElementTree, Element, tostring class A(ElementTree): __metaclass__ …

Member Avatar for Gribouillis
0
220
Member Avatar for king_koder

Since I am a Python beginner, I was thinking about studying,and possibly working on some real-world software written in Python. So could you guys suggest some simple open source projects that I could use to study and, if possible, get involved with in development. Thanks.

Member Avatar for SgtMe
0
157
Member Avatar for LoveMyPadres

I am trying to implement virtual LEDs on a Python window. I turn the LED "on" by drawing a green oval. I then use root.after() to schedule another call that turns the LED "off" by drawing a dark green oval. I use a 250ms delay. There are 4 active LEDs …

Member Avatar for LoveMyPadres
0
2K
Member Avatar for henryford

I am writing a program for python and need to create a loop that appends pay, hours, and wages to one list called lstEmp,and be able to exit the loop once you type in DONE. I am stuck please help. [CODE]def Input(): try: name=raw_input("Enter your first and last name: ") …

Member Avatar for TrustyTony
0
136
Member Avatar for Babduberance

Hi am a noob working with Apache, mod_wsgi and python. Below is some sample code on the internet that will return "Hello World!" when i go to my local server: [url]www.localhost.com/py[/url] note: I do have WSGIScriptAlias /py "C:/Users/user/site/handler.py" in my httpd.conf [CODE] def application(environ, start_response): status = '200 OK' output …

Member Avatar for Babduberance
0
186
Member Avatar for Bluerain

# I'm trying to extract the url's from the below text, without the added html tags. Is there anyway I can get just parts starting with ( [url]http://)[/url] and ending with (")? # <a href="http://www.gumtree.sg/?ChangeLocation=Y" rel="nofollow">Singapore</a>, <a href="http://www.gumtree.com.au/?ChangeLocation=Y" rel="nofollow">Australia</a>, <a href="http://www.gumtree.co.nz/?ChangeLocation=Y" rel="nofollow">New Zealand</a>, <a href="http://www.gumtree.com" rel="nofollow">England</a>, <a href="http://edinburgh.gumtree.com" rel="nofollow">Scotland</a>, <a …

Member Avatar for aml25
0
169
Member Avatar for cleve23

How can i highlight the whole line in Styledtextctrl in wxpython????I have been researching on it but i still could not get what i want. I want to highlight a whole line of sentence on the line position that i want. Can anyone help me on this???? Please........... Thanks :D

Member Avatar for deonis
0
93
Member Avatar for Syphilis

Ahoy Sailors! So I've been developing a networking application using Twisted. This can be divided into two parts. The Host and the Guest. I normally make and test such on my main Ubuntu Linux computer, Now the time has come to compile it for Windows. But straight out of left …

0
64
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
164
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
122
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
336
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
182
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
186
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
456
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
712
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
365
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
96
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
194
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
135
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
113
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
126
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
429
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
174
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
120
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
126

The End.