15,190 Topics
![]() | |
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 … | |
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 … | |
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 … | |
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: … | |
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 … | |
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 … | |
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 … | |
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 … | |
[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. | |
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 … | |
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 … | |
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? | |
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 … | |
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 … | |
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 … | |
| |
[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 … | |
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 … | |
[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") … | |
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 … | |
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 … | |
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 … | |
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...?? | |
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 … | |
[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 … | |
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 … | |
![]() | 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 … |
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 … | |
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 … |
The End.