15,175 Topics
| |
So I have this assignment where we have to create connect 4 using classes and make it so you can play against a player or computer. The problem I'm having is returning to the function if the user enters something other than one or two. I know I have to … | |
How do I recursively remove all the directories and files which begin with '.'? My test program rmdir.py does not do the job yet. Please help. Code: #!c:/Python31/python.exe -u import os from shutil import * root = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for curdir, dirs, files in os.walk(root): print (curdir) print (dirs) for d … | |
Hi folks, I wonder if anyone out there could help me with something. I have a folder containing many cnv files that look like this: * Sea-Bird SBE 9 Data File: * FileName = C:\CTD Data\Alg173\stn001.dat * Software Version Seasave Win32 V 5.38 * Temperature SN = 4977 * Conductivity … | |
I want to walk a directory and ignore all the files or directories which names begin in '.' (e.g. '.svn'). Then I will process all the files. My test program walknodot.py does not do the job yet. Please help. [CODE]#!c:/Python31/python.exe -u import os path = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for dirpath, dirs, files … | |
How can I tabulate the data strings I have saved in another file... the data sored is in the form of names and scores. The table should look like: Name Score 1 Score 2 Score 3 ==== ======= ======= ======= John 23 21 34 etc... I've started with this and … | |
I'm new to Daniweb and with Python and I'm quite bad with it to be honest D:.. Here is my code... [CODE]from Tkinter import * class App(Frame): def createWidgets(self): self.grid() self.lbspace = Label(self, text="") self.lbspace.grid(row=0,column=0) self.lbfirstName = Label(self, text="First Name:", font=("Calibri", 12)) self.lbfirstName.grid(row=1,column=0) self.firstNameVariable = StringVar() self.firstName = Entry(self, textvariable=self.firstNameVariable, … | |
Hi there, I'm currently in the process of creating a Multi-User Dungeon (MUD) in python. It'll allow multiple users to explore a text based world. I've got a basic server but i can't seem to get a client to work with it. [B]MUD server.py[/B] [code] import socket #Connect with telnet … | |
I'm learning Python to use wMaya - a 3D graphics app. While reverse engineering some code, I [URL="http://www.daniweb.com/forums/thread89440.html"]found a thread here[/URL] which explains "list comprehension". The code I'm analyzing uses that, so I attempted to deconstruct it, but I can't reproduce the same results using a for loop. I have … | |
Hello I am trying to get this program to log key presses while running hidden in the background. I have no troubles while I run this program as a .py or .pyw The trouble comes though when I have turn this file in to an .exe using py2exe It will … | |
I am currently using the Pil library for a project, however i keep running into the same problem which will not let me do anything at all. [CODE][/CODE] def bw_negative(filename): # Create the handle and then create a list of pixels. image = Image.open(filename) pixels = list(image.getdata()) print pixels[0] print … | |
I'm working with some code to have a robot do vision processing, speech recognition and text-to-speech. I'm using python2.6 and openCV The objective of the code is to have the robot recognize faces via webcam and say, "Hello." It does this more or less perfectly, except for one thing. A … | |
Many of us like wxpython,so is always fun with a new tool.:) [url]http://wxformbuilder.org/[/url] | |
Hey, I've made a program called d-cm, it's a web-development tool. I want to know if everything works and/or if it works on windows too. Therefore I'm asking if some people are willing to test it... [url="http://code.google.com/p/d-cm/downloads"]googlecode project link[/url] P.S. I'm posting it here because in the Show off your … | |
Is this needed? [CODE] class Test: def __init__(self, f): self.f = open(f) def __del__(self): try: self.f.close() except: pass [/CODE] Also, how can i open a file, and have it in append mode. However, if the file doesn't exist, python creates it? | |
Yes, you can merge two class instances in this simple manner. | |
The small code shown below works fine with Python26, however Python31 gives an error: fout.write('.snd' + pack('>5L', 24, 8*dur, 2, 8000, 1)) TypeError: Can't convert 'bytes' object to str implicitly Does anyone know what I need to do to make it work with Python31? [code]# create a soundfile in AU … | |
Hi, I'm trying to create a textgame in python, and after searching for a few topics about it I though I knew how to make it. Many textgames use a system like this: [CODE]def room_one(): #do stuff if something: room_two() def room_two(): #do stuff [/CODE] Most of the time the … | |
Here is my newest baby, the pretty.py module, born today, which I start to use instead of pprint module. Reason to make this (in addition to that it is possible to do) is that I had this problem, sorry long, LONG example: UPDATE: take out the [CODE]or j[/CODE] that was … | |
I generate an array from the folders in a directory; which is placed in an array. i then compare it for changes in the currant folder.This way i can monitor for new files that are add to the system and trigger the script. but i am having problems comparing the … | |
I know the code for sending mail is. [CODE] import smtplib fromaddr = 'fromuser@gmail.com' toaddrs = 'touser@gmail.com' msg = 'There was a terrible error that occured and I wanted you to know!' # The actual mail send server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username,password) server.sendmail(fromaddr, toaddrs, msg) server.quit() [/CODE] Basically its a … | |
I'm having this problem with passing a variable. Basically i'm trying to find every url in a HTML document. I'm doing this using the HTMLParser class (i made an extension of it). This is the code: [ICODE]class Parser(HTMLParser.HTMLParser): def __init__(self, url): HTMLParser.HTMLParser.__init__(self) req = urllib2.urlopen(url) self.feed(req.read()) def handle_starttag(self, tag,attrs): if … | |
Hey all, I'm a beginner. When i feed a list of lines into this for statement, i have trouble getting the output into a set for use outside of the for statement. [CODE] ListofWordsinLines = {} words = [] for line in ListOfLines: words = line.split() ListofWordsinLines = set(words)[/CODE] if … | |
class tennis: def __init__ (self, name, rank, tournamentsPlayed, country, racquetBrand): self.name = name self.rank = rank self.tournamentsPlayed = tournamentsPlayed self.country = country self.racquetBrand = racquetBrand #defines each thing^ def __str__(self):#creates a string return self.name + ":" + self.rank + "\n" + self.tournamentsPlayed + "\n" + self.country + "\n" + self.racquetBrand … | |
I'm trying to create a python cards game (a Brazilian cards game). But when I try to print some values (the cards played) it returns the following error: [QUOTE]Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> play() File "C:\Documents and Settings\Terminal\Desktop\Truco.py", line 71, in play print "You … | |
Hi. I am trying to get texturing to work in PyOpenGL in 2D. I have the following code so far for textures: [CODE]def tex(path): img = pygame.image.load(path) img.convert_alpha() try: ix, iy, image = img.get_width(), img.get_height(), pygame.image.tostring(img, 'RGBA') except SystemError: ix, iy, image = imgs.get_width(), img.get_height(), pygame.image.tostring(img, 'RGBA') ID = glGenTextures(1) … | |
Hi there. I am currently writing a registration program in Python, and have come across a problem. In my hours of searching, there seems to be no way to split a list that has elements obtained from [B]raw_input[/B]. Basically, I would like to take input from a user, feed it … | |
I was able to print out daily values and aggregate the final annual result but I am lost and dont know where to start on how to sum the daily values to monthly and print it out. I need your help badely. Here is part of the code [CODE] import … | |
hi all I'm trying to make a simple web using a form and method="POST" My page works fine in Firefox but fails in IE6. Can anyone tell me what I'm doing wrong ? Here is my code [code] import cgi import os import parseFieldStorage import time def test(): print 'Content-Type: … | |
so i'm almost done with my project. however, i'm still getting some errors when i run. you can find my code below. if you see any problems and know how to fix them, please, please, please let me know! class tennis: def __init__ (self, name, rank, tournamentsPlayed, country, racquetBrand): self.name … | |
[B][INDENT]below is the tutorials for developing the program i had a hard time with it. Part 1: Blackjack Card Game Blackjack is a card game played in casinos. The game is also called Twenty-One. Blackjack came originally from France, where it is called Vingt-Et-Un (21). The goal for both the … |
The End.