15,179 Topics
| |
Hey Guys : Here The problem is :to have a program to check the -(sys.argv) is long enough to have more than 3 elements if not then print "input more " -check (sys.argv) contain a specific elements for ex(P) ,& if P is found in the given elements then it … | |
[code=php] class Item(object): def __init__(self, ID, name, price, stock ): self.ID = ID self.name = name self.price = price self.stock = stock def getID(self): return self.ID def getName(self): return self.name def getPrice(self): return self._price def setPrice(self,value): self.price = value def buyStock(self, howMany): self.stock += howMany def sellStock(self, howMany): if howMany … | |
Hi, I am trying to write elements from a list that I have created to an outfile using a for-loop with this code: [CODE]for j in range(int(Allele[i])): outfile.write(' allelelocus[j] * ')[/CODE] However when I do this I just get a whole bunch of allelelocus[j] in my out file. I was … | |
I have a Python script that creates a Tkinter window running in Ubuntu. In the script I have an if/else statement that changes the background color based on a variable. That all works. What I cannot figure out how to do is when it changes the background color, I also … | |
I put the code on a pastebin thingy so this post would be easier to read. [url]http://paste.pocoo.org/show/229111/[/url] Anyways, basically, I have this 250MB text file that has a string of letters. 50 letters per line, and LOTS and LOTS of lines. I tried doing this before, but I got a … | |
Can someone help me with this code.. I get an error when I try to execute it [code] from graphics import * def main(): colour = raw_input("Enter the colour: ") win = GraphWin("Patch", 200, 200) drawCircle(win, 50, 50, colour) def drawCircle(win, x, y, colour): for i in range(5): for j … | |
Does anyone know how to download the index page from the website using a python script? For a start, I don't understand the concept, google doesnt seem to throw up any relevant articles so am a little lost! | |
Hi, I am having some trouble using the int function on an element of a list. My code currently looks like this. [CODE]for j in range(int(L)): for k in range(int(Allele[j])): alleleslocus_j.insert(k,loci.readline())[/CODE] where Allele is a list of length L inputted by the user. I am having problems with the second … | |
Okay, I'm not sure what's going on, but tkSnack [URL="http://www.speech.kth.se/snack/"](link)[/URL] is deciding to not work for me all of a sudden. I have written a full-blown freaking media player with it, and I am now failing to simply play a song from the command line. I can get it to … | |
I've got a couple of pdf's on python, but im having trouble grasping how to build classes. Was trying to do it for a poker program and i think im in over my head with that idea. (its a bit big just doing it with functions). So id like an … | |
[CODE=python]#Code should always be in a method or class #Always start variable names with lowercase, classes could be capital #input.upper() allows the user to use lower or upper case for each option import random from operator import itemgetter def isint(x): try: int(x) return True except: return False print "Invalid guess. … | |
I have a list containing strings. I want to make a directory for each item in the list, with the name of the directory being the string. Does anyone know if this can be done, and it so, how? | |
Hello people, I am writing my own python code which calls a batch file to execute a download files from the ftp, the file size varies regularly.. is there any way to pause the execution of the code until the download completes. ?? i am struck in this part of … | |
Hello, guys! I've written a GUI for a program. It's written like shit, the goal was to get it done fast. Well it didn't exactly work out, so when I refresh the data, every label disappears. Here is the code: [CODE] class GUI: def __init__(self, master): self.master = master self.label … | |
I am trying to work with cImage. But I cant get my second window to load up my img file. It always bring up a window with out the img. I have been playing with it for an hour and a half now and im thinking it has to be … | |
Hello, I've been studying PHP for a while now, and am tackling my biggest project so far. I need to parse python code (which I'm already doing) and color code it. I need to get a word RIGHT before the ( symbol. I've tried just about everything, and can't get … | |
Ugh, this is quite frustrating. I am writing a series of CGI scripts with Python that all work perfectly until I add in a stylesheet reference. Interestingly, if I put the styling rules inside the CGI script, it runs perfectly; it only throws an error when it is in an … | |
I have been working further on my text adventure (see thread: [url]http://www.daniweb.com/forums/thread285737.html[/url]) and have come to the part where I would like to manage the change of time (of day) and adjust the date as time passes. I have some code that does it, but was wondering if there is … | |
I am new to python and this is my first program. The program factorize a number given by a user. It also makes a list of all the primenumbers, that it finds and stores them in a file. Is there anybody who can see a way that I can make … | |
Hi, I have written a script which parses a UTF-8 text file and prints the required result. The code is below: [CODE] import os import sys import string import csv import codecs usage = "usage: Specify the directories for files and the RDOCK cut-off value" tm_append=[] if len(sys.argv) < 1: … | |
| Hello, I'm a Python/SPSS (DANIWEB) beginner and I'm having a hard time getting classes, functions and methods into the right order. I want to write a script for SPSS where I can read text out of an text object from the SPSS-output file. My code looks like this: [CODE=Python] import … |
[CODE]class Test: def __init__(self, number): self.number = number def getnumber(self): return self.number x = Test(54) y = 'number' print x.getnumber() try: print(eval('%s.%s'% (x, y))) except Exception, e: print(e)[/CODE] This isn't the code I want to fix, but it has the same error. I am trying to return a class function … | |
I made this program during forum discussion for accessing configuration relative to module directory, not main program's position (which can be accessed by sys.argv[0]'s directoryname). As the thread is closed I post my proves as code snippet. | |
Hi, I have got the following requirement: In a file that has many lines, i need to search for a particular line that has the word DTP. The line may be like this in the file: src 172.23.1.23 dst 192.14.2.34 DTP 0 - 65000 If the line with the word … | |
Hi, I have got the following requirement: In a file that has many lines, i need to search for a particular line that has the word DTP. The line may be like this in the file: src 172.23.1.23 dst 192.14.2.34 DTP 0 - 65000 If the line with the word … | |
I know that certain functions will check the script's or module's current directory for the file if no path is specified. [code=PYTHON]open('test.txt')[/code] If that script is run and test.txt is in the same directory that will open the correct file. However, if I try to import that module it doesn't … | |
I want to create a button with the time updating. | |
Hi, I have got a utility "sock" which is C executable (under linux) on my machine. It acts like a server or client based on the arguments passed at the command line. I want to run it through a python script. I am using the subprocess call function to execute … | |
I wrote a python program that gets input from an input file. It works fine for small input files since after opening the file I did this to get the data [code=python] data=fPtr.readlines() [/code] Since readlines only takes the input data and packs it into a list, it is clear … | |
I would like to be ablt to display 25 circles with alternating colours of red and white? But the code I produced does not work.. plz help. from graphics import * w = 300 h = 300 win = GraphWin("Red Circle", w, h) center = Point(150, 150) radius = 80 … |
The End.