15,181 Topics

Member Avatar for
Member Avatar for thesinik

Alright so I want to write a program that will compute trig functions (sin, cos, tan, arcsin, etc.). Basically I'm ignoring the included math library in python and hard coding it myself. My issue is that I'm fairly new to programming and not sure how to go about coding a …

Member Avatar for thesinik
0
4K
Member Avatar for Yeen

I understand the basic principle of recursion, but I'm having trouble implementing it in practice. I understand this first case perfectly fine. It works because n is constantly getting closer to 0. [CODE]def faculty(n): # Base case if n == 0: return 1 # Recursive call else: return n * …

Member Avatar for Ene Uran
0
121
Member Avatar for SoulMazer

Okay, so I'm having a little trouble. Let's say I run "scriptA.py" and it has a GUI (Tkinter) and it is running in its mainloop. I want to create a "scriptB.py" that can end "scriptA.py"; would there be a way to do this regardless of the OS it is on …

Member Avatar for SoulMazer
0
267
Member Avatar for lewashby

In the following program I don't understand the [COLOR="Green"]staticmethod[/COLOR] or what is has to do with [COLOR="Green"]Critter.total[/COLOR]. From what I can see, total is a class attribute and [COLOR="Green"]Critter.total[/COLOR] is accessed from the [COLOR="Green"]__init__[/COLOR] constructor method. Thanks for any and all replies. [CODE]# Classy Critter # Demonstrates class attributes and …

0
64
Member Avatar for ffs82defxp

Its not running [CODE]import math import os cls = os.system("cls") title = os.system("title Pythagorean Theorum Solver") def MainLoop(): cls print "Enter 3 coordinate plane points (x - y) format" print "" firstPair = input("--> ") SecondPair = input("--> ") MathPart() def MathPart(): '''structure of the formula: squareRoot of --> (x-y)^2 …

Member Avatar for vegaseat
0
140
Member Avatar for ShadyTyrant

I am designing a module to perform some actions for a library database application. The methods are not implemented yet but I was wondering what you all think about nested classes in this situation. Design One [CODE=Python] #!/usr/bin/env python # File: .py # Author: shadytyrant@gmail.com # Date: 2009-11-25 # Notes: …

Member Avatar for ShadyTyrant
2
258
Member Avatar for lewashby

In the following program, I'M getting the following error message when I try to run it. [COLOR="Red"]TypeError: object.__new__() takes no parameters[/COLOR] [CODE] # Classy Critter # Demonstrates class attributes and static methods class Critter(object): """A virtual pet""" total = 0 def status(): print "\nThe total number of critters is", Critter.total …

Member Avatar for pythopian
0
546
Member Avatar for furblender

Completely frustrating - I have been googling for a solution for this for a couple of hours now. I have this little bit of code that I wish to read a text file into a Python Dictionary. I used this dictionary format internally within the another piece of code I …

Member Avatar for furblender
0
3K
Member Avatar for persianprez

I know I can go back and edit all my output with %f.3 is there code to do this for all output?

Member Avatar for vegaseat
-2
85
Member Avatar for peepeep

Hi, I have a problem with my matrix program. i created and initialized my matrix now i have to file the matrix with values of corr. i want it to look like this [COLOR="Red"][1, 0.1, 0.2, 0.3] [0, 1, 0.4, 0.5] [0, 0, 1, 0.6] [0, 0, 0, 1][/COLOR] [CODE][/CODE]file …

Member Avatar for woooee
0
101
Member Avatar for Musafir

I need to make a score table function which keeps a track of the points. the first player to reach 11 points wins, however the game must be won by aleast a 2 point margin. the players points should be displayed on two halves of the graphic window. for example: …

Member Avatar for vegaseat
-3
278
Member Avatar for reduxmachine

Hello I am quite stuck on a python exercise and not quite sure how to finish it. My task is to draw an eye using a graphics module, and when the user clicks the mouse on the eye, the program is to specify what part of the eye was clicked …

Member Avatar for woooee
0
110
Member Avatar for laccko

I need to use a semaphore simulator Sync.py that is written in Pythone and new program (also written in Pythone) is added as parameter. There is problem with classical syntax of If statement, I do not know how to write there else branch as well as more than one command …

Member Avatar for woooee
0
139
Member Avatar for Kruptein

How can I start a launcher from python? if I do: [icode]os.system("~/localhost")[/icode] it just returns a number (probably a process id or something) if this is not possible, how can I start from python a terminal window and execute a code in that terminal? (without closing the python script) Thanks …

Member Avatar for Kruptein
0
199
Member Avatar for Musafir

The function has two parameters, one giving the side-length and the other giving the length of the shortest line. The function should draw as many lines of the spiral that fit inside the window def spiral(lenght,side): for i in range(1,side+1,5): lenght.forward(i) lenght.right(90) I made a start of the code, please …

Member Avatar for woooee
0
114
Member Avatar for ffs82defxp

I'm making a macro in python and I need some help. Basically, it just loads up 4 line entries from a text file and just attaches those 4 things to the end of a URL, and opens firefox to that URL. It then waits a random time between 3min-8min and …

Member Avatar for ffs82defxp
0
273
Member Avatar for Tech B

I cam up with this when I seen what Johnny Lee can do with a wiimote. Youtube it to check it out, pretty amazing. I realized not everybody has a wiimote or a bluetooth dongle to connect it to the PC, so I used my webcam and python. The webcam …

Member Avatar for Tech B
0
878
Member Avatar for bsod1

I'm writing some basic programs on python and I need an IDE with advanced code completion(like bpython). I've tried eric, eclipse, IDLE but those are not good at code completion, I need something like bpython(if you don't know, just try, it's great at code completion and hints)

Member Avatar for AutoPython
-1
89
Member Avatar for leegeorg07

Hi again, I'm now working on a twitter client and I'm wondering how people update their programs when it needs it, for example when I commit a change. Any help on the subject would be most appreciated thanks

Member Avatar for Stefano Mtangoo
0
196
Member Avatar for MRWIGGLES

if i had a data file with html/xhtml tags: Code: <html> <head> <title> data file </title> </head> <body> <center><h1> heading 1 </h1></center> <b>bolded</b> <P>paragraph</P> <P> <br /> how would get a python program to read ONLY the start and end tags and and enqueue them in a queue? for example, …

Member Avatar for vegaseat
0
212
Member Avatar for P00dle

I have to read through a text file and replace all occurences of [CODE]%%CNT1%%[/CODE] with the value of a counter. The part of my code that does the actuall replacements looks like this: [CODE]for i in range(1, (count1 + 1)): out.writelines(re.sub("%%CNT1%%", str(i), text))[/CODE] This works fine. Now what I need …

Member Avatar for P00dle
0
63
Member Avatar for El Duke

Hello all, I have been developing a code based on Google Translate Python Wrapper. I have done it all, perfectly, except for one thing, I will explain it by pointing to code: there is the defined global languages list, and there are two main functions (Translate(), and UserSubmitted() ) now …

Member Avatar for El Duke
0
127
Member Avatar for awn

Hi, I'm writing an application in python to read data from a joystick and display it onto a screen with a background image overlay. i used the canvas widget to display the data to my screen. The problem is, the text keeps updating the entries without clearing the previous entry …

Member Avatar for awn
0
781
Member Avatar for Archenemie

28 Minutes Ago | Add Reputation Comment | Flag Bad Post One last problem with my script, it returns this error message... [CODE]Traceback (most recent call last): File "C:/Python26/Renamer 3", line 23, in <module> os.rename(fname, b)WindowsError: [Error 2] The system cannot find the file specified.Traceback (most recent call last): File …

Member Avatar for Archenemie
0
215
Member Avatar for persianprez

I cannot find one example of somebody doing this, only sorting by the first item. Here is my code: [CODE] dict.sort() for key in dict.keys(): print key, "%8s"% dict[key] [/CODE] I'm only getting an alphabetical sorting of the left side of the dictionary.. like this: a:4 c:3 b:12 a 4 …

Member Avatar for persianprez
0
248
Member Avatar for lewashby

Does anyone know how to get Wing IDE to work with iron python? But I would also like to keep quick access with WING IDE to my standard python as well. Thanks.

Member Avatar for Stefano Mtangoo
0
34
Member Avatar for sneek

Hi, the Python/C-API says that we allways have to return owned references. Example: [CODE] // C-Code static PyObject * f (PyObject *self, PyObject *args) { PyObject * rtn = NULL; PyArg_ParseTuple(args, "s", &rtn); Py_INCREF(rtn); return rtn; } [/CODE] [CODE] #Python-Code a=myType() b=a.f("hello world") a.f("hello world") [/CODE] I understand the first …

Member Avatar for sneek
0
78
Member Avatar for vegaseat

This code snippet shows you how to sort more complicated objects like a list of lists (or tuples) by selecting an index of the item to sort by.

Member Avatar for Ene Uran
2
369
Member Avatar for gangster88

I need the function to display a set of eyes, so if i call the function Eyes(3,4) a graphics window opens with exact dimesions for 4 coloumns and 2 rows of eyes... [code] from graphics import * def drawCircle(win, centre, radius, colour): circle = Circle(centre, radius) circle.setFill(colour) circle.setWidth(2) circle.draw(win) def …

Member Avatar for battlecrab
0
111
Member Avatar for rjmiller

alright, so i'm trying to import text from a file into an array so that I have the ability to edit data, find certain functions, etc. This is currently what my program looks like....(I haven't gotten very far) from scipy import * from numpy import * def Radiograph_data: try: file('c:/users/ross/desktop/radiograph_data.txt') …

Member Avatar for pythopian
0
207

The End.