15,190 Topics

Member Avatar for
Member Avatar for G-nerd

I need to make the user ask for an English sentence and then make it produce the spanish translation of it from a given data base which is given in list form. I also want the user to keep asking for a english sentence until I type in a character …

Member Avatar for Lardmeister
0
232
Member Avatar for alberttruism

Hullo, I’ve been banging around all week (after re-install of Snow Leopard) trying to get python configured with MacPorts, OpenCV, and PyGame (at least). I’ve got python_select properly configured and seemingly working, but I can’t seem to get any of these modules including all at once. Currently I can include …

0
89
Member Avatar for knan

Hi can anyone tell me how to remove empty keys in the following dictionary d={'a':[],'b':['1','2'],'c':[]} I want it to be d={'b':['1','2']} I tried this. But its showing error. I know its wrong to change the size of a dictionary during iteration. But is there any other way? [CODE]>>> for x …

Member Avatar for TrustyTony
0
18K
Member Avatar for Thropian

as part of a game I'm making I decided to make an importable/executable file to shorten the code and I was wondering... [CODE]def view(N,W,E,S): if info_dict["direction"] == "north": if N != 1: pic = fwall wall = "yes" if N == 1: if W != 1 and E != 1: …

Member Avatar for Gribouillis
0
88
Member Avatar for danholding

how do i get round this error then because i have a mixed list of file names and their size i need it sorted by the size and i get errors trying to sort the size on its own because of they way it pairs the file name and the …

Member Avatar for TrustyTony
0
104
Member Avatar for haojam

Dear Sir, I have written a script to extract the first line starting with [COLOR="Red"]Source Name[/COLOR] AND ends with [COLOR="red"]Comment [ArrayExpress Data Retrieval URI][/COLOR] and i have done it but i could not parse distinct or unique attributes which is not repeated in every files. I would like to parse …

Member Avatar for haojam
0
686
Member Avatar for tachyonshower

hi, i was just wondering if someone could point me in the right direction on how i would go about writing up code for displaying a plane-collection of harmonic oscillators. i would like to display them as oscillating spheres. i have code written up for graphing 1-d coupled oscillators and …

Member Avatar for tachyonshower
0
323
Member Avatar for bretthay93
Member Avatar for longlongsilver

I have to use the function [I]ask_number()[/I] so that is ask the player for a guess with a call to [I]ask_number()[/I] here is my code but it automatically guess the number and i dont know if i did it right [CODE]import random print "\tWelcome to guess my number!" print "nI'm …

Member Avatar for longlongsilver
0
920
Member Avatar for z00t

[COLOR="Red"][U]PYTHON:[/U][/COLOR] I have no idea where to start this, but i need to write code that takes a list of real numbers as input and returns the average of the numbers in the list. any input as to how i would go about starting this code would be much appreciated.

Member Avatar for richieking
0
119
Member Avatar for Asset

How would I write a code to read in this book.txt [CODE]title*Programming PHP author*Lerdorf, Tatroe and MacIntyre publisher*O'Reilly Media description*3 This book covers the PHP programming language. It assumes the reader has some programming experience. It covers connecting to Oracle and MySQL databases. title*Core PHP Programming author*Atkinson publisher*Pearson Education description*3 …

Member Avatar for Asset
0
331
Member Avatar for kuchi

We have a module called "cart.items" and imported this in another PY code to use classes. I did import classed under cart.items like ("from cart.ltems import Items") and used Items class in my code. When I run my PY code in UNIX box, I get that problem. What I ve …

Member Avatar for richieking
0
558
Member Avatar for Thropian

I'm making a little game and I can't get button bindings to work. Here is what I have so far [CODE]def forward(event): print "up" frame.bind("<Up>",forward)[/CODE] but pressing the up arrow does nothing...is there something I missed?

Member Avatar for TrustyTony
0
147
Member Avatar for convoluted

Hello all. I'm trying to get a video feed in a wxPython GUI (under MS Windows) and thought about using OpenCV. There is a short tutorial on how to achieve this at this page: [url]http://opencv.willowgarage.com/wiki/wxpython[/url] (updated late 2009). The problem I'm having is trying to load the libraries to get …

Member Avatar for convoluted
0
379
Member Avatar for TrustyTony

Here another small snippet of mathematical nature returning all possible divisors of number. (set is, by the way, needed because of perfect squares Not possible to edit the snippet part but here the same with less stupid command line interface (not repeating the loop): [CODE]def divides(n): return sorted(set(sum( ([x,n/x] for …

Member Avatar for TrustyTony
1
860
Member Avatar for sneek

Hi, I read the Python/C-API and they say I should not use PyArg_Parse() anymore but use PyArg_ParseTuple(). My problem is that I retrieve an PyObject * out of PyDict_GetItem(...) so this is a single object and not a tuple. PyArgs_Parse() is the only API-Function to get a C-"string" out of …

Member Avatar for Gribouillis
0
2K
Member Avatar for kur3k
Member Avatar for richieking

[B][COLOR="Red"]IS ANYONE INTERESTED IN THIS APP???[/COLOR][/B] I am looking for guys 1 or 2 to write some open source application in python. We will decide what app. we want to write. 1.App in GUI (wx) 2.The app will have its dedicated website. 3. The app in multi platform And other …

0
102
Member Avatar for jgritty

I'm not a huge contributor on these forums, but I do read a lot. Anyhow, I have "completed" a couple things I've been working on in the last couple weeks, and thought I would share. [url]https://bitbucket.org/jgrigonis/mortgagecalculator[/url] A simple mortgage calculator written in python using tkinter that lets you calculate any …

0
73
Member Avatar for singlem1905

[I][CODE]execfile('comp1.py') def exefi(name, locals=None, globals=None): exec compile(open(name).read(), name, 'exec') in locals, globals exefi('comp1.py')[/CODE][/I] it can execute successfully. but [I][CODE]#execfile('comp1.py') def exefi(name, locals=None, globals=None): exec compile(open(name).read(), name, 'exec') in locals, globals exefi('comp1.py')[/CODE][/I] it come with "File "comp1.py", line 39, in <module> ex=c.end() File "comp1.py", line 17, in end return compile(string.join(self.code, "\n"),"<code>","exec") …

Member Avatar for singlem1905
0
118
Member Avatar for Safia Abdalla

I have been working on this simple text editor using Python 3 and Tkinter. This is my first time creating a program with an actual GUI and I have relied only on Tkinter documentation. I managed to create a text editor. However, we I started working on the commands of …

Member Avatar for TrustyTony
0
457
Member Avatar for victordq

Hi guys, Can anyone help me to fix my code so I don't get the unexpected unindent error? The code is very big, so I'll only post a small part so you can help me. I'm using the PyScripter IDE. [CODE]def pegar_dados_serial(): ser = serial.Serial(port='COM4', baudrate=115200, timeout=2) #Rotina para leitura …

Member Avatar for richieking
0
3K
Member Avatar for keltik

Hello, First of all: I'm more used to java, but at university we need to code something in python. I'm having serious problems filling a python-list with values. [CODE] for i in range(self.num_of_players) : self.player_hands[i]=["Testcard"] [/CODE] I want to fill the i-th player_hands-list with a String! Yes i declared a …

Member Avatar for keltik
0
172
Member Avatar for knan

We know that 0.1 + 0.1 + 0.1 - 0.3 = 0.0 But in python 0.1 + 0.1 + 0.1 - 0.3 = 5.5511151231257827e-017 Is there any way I can get 0.0...??

Member Avatar for knan
0
197
Member Avatar for HoneyBadger

Guys I wrote a program that creates 23 random numbers(birthdays) and the counts how many duplicates are there. How come [B][U]sometimes[/U][/B] when I run this it returns "None"? Here is the code: [CODE]import random #Checks for duplicates. def has_duplicates(userstring): userlist = list(userstring) list_len = len(userlist) len_no_duplicates = len(set(userlist)) if list_len …

Member Avatar for richieking
0
98
Member Avatar for Sykee

[CODE] import subprocess import os def main(): quickfile = file_existance() quickdraw = subprocess.Popen(['java', '-jar', quickfile],\ stdin = subprocess.PIPE, \ stdout = subprocess.PIPE) event = WindowEvents(quickdraw) def file_existance(): filename = raw_input("Please enter the location of quickdraw: ") while (not os.path.isfile(filename)): print "That file does not exist, try again" filename = raw_input("Please …

Member Avatar for WildBamaBoy
0
247
Member Avatar for Banjoplucker

Hello, I'm new here, so please be gentle. I have posted my code at the following page: [url]http://www.bpaste.net/show/11397/[/url] In short, I need to read in my file, block by block, but have the re.finditer regular expression report the offsets relative to the beginning of the overall file, rather than relative …

Member Avatar for Banjoplucker
0
107
Member Avatar for tottletj

Basically I've looked everywhere for help with this problem and been unable to find any so i thought i'd ask here. I have a text file full of numbers which i wish to manipulate. the actual text file has about 200 rows and 10 columns, but in this example i'll …

Member Avatar for Gribouillis
1
102
Member Avatar for Archenemie

Ive made this quick program to strip the "youtube - " prefix off my mp3 collection, so i started modifying a script i had made before to replace file names with a <filename><incrementing number> type name. It has gone well so far, with the only problem being it will strip …

Member Avatar for Archenemie
0
2K
Member Avatar for Arbolito

Hey guys. I'm working on a simple hangman program. I got the core engine down working in a command prompt, and now I'm making it using classes and a GUI. I'm using tkinter. Anyway, everything works with no error, but the image is not displaying at all. Here is the …

Member Avatar for KWL
0
1K

The End.