15,175 Topics
| |
I wanted to try something seemingly easy, but I can't wrap my head around this. I want to open a .txt file, remove all dots from the text, and write the altered .txt as a new file. [CODE]#!python def process_file(): infile = open("dots.txt", "r") outfile = open("no_dots.txt", "w") for x … | |
I recently wrote a thread about help with classes. I got a lot of good responses but I am still struggling with more complicated stuff. I have an old project that I wrote a few weeks into learning python. I am now suppose to turn this project into a class. … | |
Well, I've written a simple program that gives you info about your computer. The program runs perfectly fine, but the console window pops up and really does nothing. So I would like to hide the console window and only show the gui frame. Pointers on how to do this? | |
This is a sample code I looked up. I am a rookie and I do not really understand it. [CODE]n = int(input('Enter an interger >= 0:')) fact = 1 for i in range(2,n+1): fact = fact*i print(str(n)+' factorial is '+ str(fact)) [/CODE] My biggest problems are: 1) for i in … | |
Hi all. I am very new at python and so i am having trouble with the simplest things, and i dont understand why this: newfile = raw_input('what do you want to name your new file?') text_file = open (newfile, "w") isn't working. Can somebody explain it? Thankyou | |
[CODE]import Tkinter class converter(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() self.labelVariable = Tkinter.IntVar() welcome = Tkinter.Label(self, textvariable=self.labelVariable, anchor="w", fg="black", bg="lightgrey") welcome.grid(column=0, row=0, columnspan=3, sticky='EW') self.labelVariable.set(u"Hello there. Welcome to MAKK's currency converter.") self.entryVariable = Tkinter.StringVar() self.entry = Tkinter.Entry(self,textvariable=self.entryVariable) self.entry.grid(column=0, row=1, sticky='EW') self.entry.bind("<Return>", self.OnPressEnter) self.entryVariable.set(u"Enter currency here.") money … | |
hello, i'm new to this website and well only have a few months of python exp. i decided to make a small, simple rather easy if HUMOR game. When is started, i did not know a whole lot other than how to make lists and scenes and make a way … | |
How could I call function by clicking in the graphics window. I currently have a draw eyes function but i want to be able to call it by clicking on the graphics window and call 30 eyes in the same colour sequence of blue, green and brown? so i could … | |
Hi y´all. I´m more than a little green at this and have been trying to get an understandig of Python. I came across WXPython and decided to try the first program in the tutorial by Fuze I´ve downloaded and installed python 2.6.3 and Wxpython 2.8.10.1. I´ve also got Python 3.1 … | |
These three things are holding me back. 1. The new style class object parameter - [CODE]class MyClass(object)[/CODE] [INDENT]Note that I'M also also not familir with the old style[/INDENT] 2. The [CODE]_init_([/CODE] - constructor, or any constructs for that matter. 3. The [CODE](self)[/CODE] parameter. How is it different from the normal … | |
Hi everybody, I'm trying to write a function that takes in 2 values, a min and a max, that prompts the user to enter a value within that range, and uses 0 as a sentinel to quit the loop. My issue is, I also want the loop to continue prompting … | |
Hi, I wrote this sample code to check the integrity of an IBAN (International Bank Account Number) bank account number. (See Wikipedia for further information) Any advice to simplify this? [code=python] # # IBAN_Check.py # Utility to check the integrity of an IBAN bank account No. # Python 2.5.1 # … | |
Why is it that if input 1, line 1 isn't deleted in a.txt? [code] x = open('a.txt','r') l = [] q = 0 for line in x: l.append(str(line)) b = "".join(l) print b a = raw_input("Which line do you want to delete?: ") l[int(a)] = "" x.close() x = open('a.txt','w') … | |
Hi, I am new to python programming. I am interested in writing a HTTP proxy using poll or twisted. I know how the tunnel works but I am not sure of starting the code. I need help from experts to complete the programming. As far as I know a tunnel … | |
I'm trying to make a tower defense game, i got all my tiles setup, but i need help with selecting a tower and placing it anywhere in the tile. This is an example of my tower class: class Missile(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.cost = 100 self.selected = False self.image = … | |
I need to parse an assembly program. I have no problems parsing a group of instructions or a group of instructions with one loop. For example: [CODE] LD R2, 0(R1) DADD R4, R2, R3 SD 0(R1), R4 DADDI R1, R1, #-8 DADD R2, R2, R4 or Loop: LD R2, 0(R1) … | |
Hey Everyone. I'm back. I started a Python project that actually got close to completion back about six months ago. Most times when i requested help i was often suggested that i don't use v3 of python as many things changed (someones help code was for 2.x and didn't work) … | |
I want to be able to draw an eye for a colour inputted by the user. If the user enters the colour green,brown or blue then the eye should be drwan orelse an error message saying "not a valid colour" should be outputted [code] from graphics import * def drawCircle(win, … | |
I'll keep this simple for now Can a windows (7) gadget be made with python or does some microsoft type development kit need to be used? Thanks | |
Say I've written a function that will take an unlimited number of arguments and store them under different variables. Since the use is able to input any number of strings, it's not possible to give names to all the variables that might be created. So, how would I create variables … | |
Hello. Here I go again. I tried to create a computer enemy for my connect 4 game: [CODE] def turn_comp(): import random print 'Computer ist am Zug!' playchip = random.randint(0, columns) board[0][playchip] = 'O' print_board() [/CODE] Even though I limited the range of randint with 0 and columns (in a … | |
Hello. Here I am again with my Connect 4 project and another board problem. This is my code: [CODE] fielda = [] fieldb = [] rows = int(raw_input('Height: ')) columns = int(raw_input('Width: ')) if rows < 4: rows = 4 if columns < 4: columns = 4 def print_board(): for … | |
I want to be able to move the iris and the pupil of the eye, if I click on the left of the graphic window irrsepective of high or low then it should move left and if i click on the right then if should move right. if i click … | |
Hi, While running my Python Script I am getting "org.python.core.PyInstance" ERROR. I am not getting why this ERROR is coming. Please help...... | |
Hi all, can anyone help me with writting the code that does: [CODE] n=5 for i in range(0,n,1): answer=a*i #a is an array,say([2,3,4]) return answer [/CODE] basically I want compute a*i and return answers when i=0,1,2,3,4 ,and the answer should be a 3*n matrix, first row is when i=0, second … | |
I have a couple of issues with my lab assignment for this week. I was wondering if you guys could help. I will post the assignment and then post my code thus far. Thank you. )Write a program that will display the menu below until user decide the quit the … | |
I am using BeautifulSoup for my project and I don't know how the object returned by the Soup is organized, so I don't know how to access it, except using only print I can only do this: [CODE]link = soup.find(attrs={'class' : re.compile("util2$")}) print link [/CODE] it print out the whole … | |
Hi there, Im writing a program that takes a function and makes a plot of it. the program consists of 2 functions and each creates its own GraphWin. However i want to have a mouse click at the end close both windows. So i returned the window from the first … | |
Hi, Im using wxPython for my latest project and i was wondering, how do i make the window go to the best size, so it includes all of the objects on screen? I used to be able to remember... but i forgot :P | |
PlugIns in their simplest form can be just python modules that are dropped into some designated directory and dynamically loaded by the main application. This snippet can be used to do just that. [B][U]Usage[/U][/B] To load plugin modules: [CODE]>>> plugins = importPluginModulesIn('mypackage') >>> plugins {'foo': <module 'foo' from 'mypackage\foo.py'>, 'bar': … |
The End.