Posts
 
Reputation
Joined
Last Seen
Ranked #4K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
6
Posts with Upvotes
6
Upvoting Members
4
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
1 Commented Post
0 Endorsements
Ranked #818
~35.9K People Reached
Favorite Forums
Favorite Tags

46 Posted Topics

Member Avatar for Zebibyte

I'm actually fairly new with Python, but I have some experience with other languages, and in alot of languages, they won't keep floats exactly as we want them too. Try multiplying everything by 100 until you need to display it to the user. So 50 cents would be 50 instead …

Member Avatar for newbieee
0
748
Member Avatar for Findlebot

Without going into the full process, I would probably read every line into a list and break each line down into a list of characters. That way, you have a list such that list[2][3] refers to 2 rows down and 3 characters over in the maze. I would also have …

Member Avatar for 0x69
0
3K
Member Avatar for Mathhax0r

Is it possible to have a function run at the beginning of every function of a class without explicitly writing it? I'm going to have a class with 20 or so methods, and though I can just copy and paste, I was wondering if there was an easier way to …

Member Avatar for jcao219
0
11K
Member Avatar for Yodamadashi

I'm not quite sure what you are doing with the whole of the code, but I get what you want. Let's say you have three different lines of code, and a random number between 1 and 3. If it's 1, you execute the first line, if it's 2, you execute …

Member Avatar for sharmine
-1
718
Member Avatar for Mathhax0r

I'm working on a game in pygame, and I decided I wanted to make it load flash files for the characters in battle so I could animate them in flash. Is there a module that will allow for easy displaying of multiple flash files, and also for skipping to certain …

Member Avatar for deonis
0
92
Member Avatar for El Duke

I would use a virtual machine with windows and python on it and install the win32 module. There's no good way to simply replace it.

Member Avatar for El Duke
0
155
Member Avatar for charlottetemp

When printing multiple things, seperate them with a comma. For instance: [code] distance = 15 print "The distance is", distance #Output: The distance is 15 [/code] However, there's a better was to do it: [code] distance = 2.873430192 print "The distance is %.2f miles." % distance #Output: The distance is …

Member Avatar for charlottetemp
0
7K
Member Avatar for gangster88
Re: list

You pretty much had it there. Just use some string formatting. [code] def displayDate(day, month, year): m = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] return "%d %s %d" % (day, m[month-1], year) [/code]

Member Avatar for vegaseat
0
104
Member Avatar for cnuzzo

So you want 3 slots on the body where you can have armor, and some armor can take up more than one of those slots, and you want to have armor equipped only in the slot it should go in if it can? If that's the case, the character could …

Member Avatar for Mathhax0r
0
364
Member Avatar for scrace89

I'm really surprised no one's helped you, yet. You did alot of the work already. For the first one, first blank, you're trying to get every character of the word except the last one, since the last one is punctuation. [ICODE]-1[/ICODE] will do just that. For the second blank, I …

Member Avatar for scrace89
0
398
Member Avatar for johni12

Being as general as possible, you could pass a list to a function, and if there's a new item not in that list, it's appended to it. If it's already in the list, then you can return true for repeats or w/e. [code] def doesListHaveRepeats(baseList, whereAt=0, tempList=[]): if whereAt == …

Member Avatar for johni12
0
251
Member Avatar for andrewktmeikle

[code] def removePostfix(argWord): leaves = "s", "es", "ed", "er", "ly", "ing" for leaf in leaves: if argWord[-len(leaf):] == leaf: return argWord[:-len(leaf)] [/code] Here's for you're first problem.

Member Avatar for andrewktmeikle
0
2K
Member Avatar for axa121

Something along these lines: [CODE] lineCount = 0 while True: theTxt = raw_input("") if theTxt == ".": break lineCount += 1 print theTxt*3 [/CODE] Obviously you can replace the [ICODE]print theTxt*3[/ICODE] with whatever you want, but that's the jist of it.

Member Avatar for masterofpuppets
0
189
Member Avatar for MRWIGGLES

[code] theySaid = raw_input("Please enter a, b, or c: ") if theySaid not in ["a", "b", "c"]: print "You didn't follow my instructions. Sad Panda..." [/code]

Member Avatar for woooee
0
141
Member Avatar for goisagi

Could you rephrase that? I'm not sure if this is what you're after, but: [code] while True: surv1.set_sex = raw_input("What's your gender?") if surv1.set_sex in ["m","f","n"] break else print "Please answer m (male), f (female), or n (neither)." [/code]

Member Avatar for goisagi
0
78
Member Avatar for marcux

A quick google search of "python special class methods" pulled up this: [url]http://diveintopython3.org/special-method-names.html[/url]

Member Avatar for Gribouillis
0
192
Member Avatar for sneekula

If by manually you mean with 2 for loops or a list comprehension. [CODE] listX = [[0 for i in range(1448)] for j in range(50)] [/CODE]

Member Avatar for Mathhax0r
0
1K
Member Avatar for Yeen

You can use helper functions, you know. [CODE] def harmonicSum(n): def realSum(p): if p > n: return 0 return 1/p + realSum(p+1) return realSum(1) [/CODE] There's probably a more eloquent solution, but what works, works. It also allows you to modify the function slightly to get numbers of the form …

Member Avatar for Ene Uran
0
126
Member Avatar for ffs82defxp
Member Avatar for ffs82defxp
0
304
Member Avatar for jaison2

[CODE] def population_growth(argBase, argMax, argRate): assert argBase < argMax assert argRate > 0 theAnswer = [argBase] iterAnswer = argBase while True: iterAnswer *= 1+argRate theAnswer.append(iterAnswer) if iterAnswer > argMax: break return theAnswer uBasePop = int(raw_input("Enter the base population: ")) print population_growth(uBasePop, 1000000, .08) [/CODE] I didn't know what you're needs …

Member Avatar for leegeorg07
0
112
Member Avatar for ffs82defxp

If you open a file with the [ICODE]open()[/ICODE] function to write in, and it doesn't exist, then it will be created automatically. Is this what you're looking for? For example, to use your code: [CODE] theFile = open("C:\test.txt","w") [/CODE] EDIT: Wow, my bad, the post below me ninja'd it. I …

Member Avatar for vegaseat
0
129
Member Avatar for lewashby

Python has a built in debugger named pdb (Python DeBugger, lol) that will let you do just that. Check out [URL="http://pythonconquerstheuniverse.wordpress.com/2009/09/10/debugging-in-python/"]this article[/URL] for its use and some other debugging

Member Avatar for Mathhax0r
0
79
Member Avatar for chunalt787

Whenever you have an error when dealing with someone else's code that they posted publicly that is relatively popular, it's good to assume that you're code has the error rather than their code. Does [ICODE]MyPhotoSets[0][/ICODE] contain a Photoset object? Maybe you should check.

Member Avatar for Mathhax0r
0
148
Member Avatar for gangster88

The function range(x,y) returns the list x,x+1,x+2,...,y-1 and stops there. If you wanted to print out x through y in your above function, you should change it to [ICODE]range(first, last+1)[/ICODE]

Member Avatar for Mathhax0r
0
139
Member Avatar for ffs82defxp

Lol, try making 1000 into 100000. It's doing it too quick and rounding down the time.

Member Avatar for woooee
0
106
Member Avatar for python user

Yes, you make a Monster class, and a Weapons class, and in the constructor of the Room make a list of the monsters and a list of the weapons.

Member Avatar for Mathhax0r
0
133
Member Avatar for scrace89

How about: [CODE] area = ((length**2)*numosides/4) / math.tan( math.pi/numosides ) [/CODE] Area isn't in degrees...

Member Avatar for vegaseat
0
121
Member Avatar for python user

Look at the beginning of prompt_cell. You misspelled one of the global variables. :) However, your code looks extremely ill-formed. Though it will work like this, this is a very shakey way to write it. Do you know what classes are? Also, you can pass functions as arguments, so you …

Member Avatar for python user
0
215
Member Avatar for gangster88

Here's a technique commonly used to sanitize input: [CODE] keep_going = True while keep_going: choice=int(raw_input("please enter your choice(1 = rock, 2 = scissors, 3 = paper): ")) if choice == 1: choice = 'rock' keep_going = False elif choice == 2: choice = 'scissors' keep_going = False elif choice == …

Member Avatar for sentinel123
0
238
Member Avatar for sentinel123

Do you have something against functions that take arguments? You have a lot of functions that could be many into one or two functions with an argument or two. Even if you don't use OOP, getting rid of global variables and putting some functions with arguments into place can't hurt …

Member Avatar for sentinel123
0
315
Member Avatar for sentinel123

Use the print function I gave you in the previous thread. For filling the board with blank (-) spaces, you need a seperate function (i.e. the one you have above called print board) to initialize the board. [CODE]GameBoard = [] #this will be the main game board def initialize_board(argR, argC): …

Member Avatar for sentinel123
0
131
Member Avatar for krishna_sicsr

You know, it might be helpful to post up your code so we can find errors in it.

Member Avatar for jlm699
0
84
Member Avatar for mahela007

[QUOTE=mahela007;1045329]So how does a toolkit eliminate the need to write that fundamental code? With the massive number of different graphics cards available today, how could a toolkit possibly know how to access the memory of the video cards? [/QUOTE] How does Windows, or Linux, or <Insert OS Here> know how …

Member Avatar for mahela007
0
261
Member Avatar for sentinel123

The best solution I know of is to print out each thing manually. Example: [CODE] for row in fielda: for spot in row: print spot, print [/CODE]

Member Avatar for sentinel123
0
2K
Member Avatar for Judgment

The first two only require one liners of logic, so here: [CODE]n = int(raw_input("How many squares? ")) squares = [x*x for x in range(1,n+1)] print square[/CODE] [CODE]def even_only(argList): return filter(lambda m: m%2==0, argList)[/CODE] As for the pig latin, you'll need to break the sentence down into words with split, do …

Member Avatar for vegaseat
-1
151
Member Avatar for truekid

Normally I'd suggest to use something like mathplotlib, but since he gave you graphics.py, he probably wants you to use it to draw the histograms. Could you attach it to your post?

Member Avatar for truekid
0
322
Member Avatar for Ri0o

Assuming you already know how to read in from files, there's a wonderful plotting tool for python called [URL="http://matplotlib.sourceforge.net/"]matplotlib[/URL] that will let you make your pie chart. You'll have to get numpy first, though. Btw, your link to the text file is broken.

Member Avatar for Ri0o
0
177
Member Avatar for Mathhax0r

My issue is essentially spelled out in the title. I want to be able to catch clicks (more specifically double clicks) on icons on the desktop or in folders or wherever, and tell where the click was on the icon (the coordinates of the click along with the whole size …

Member Avatar for Mathhax0r
0
106
Member Avatar for kenmeck03

This sounds suspiciously like homework, so I'll just give you a hint. someList.index(item) returns the index of the item if it's in some list. Otherwise, it'll throw ValueError. Example: [CODE]listA = [1,2,3,5] try: listA.index(4) print "Four is in the list." except ValueError: print "Four isn't in the list."[/CODE]

Member Avatar for vegaseat
0
114
Member Avatar for i are smart

I've never used turtle before, but that looks similar to Pickle and cPickle. The difference between those two is that since python is kinda slow, they redid the Pickle library with C (cPython) to make it alot faster.

Member Avatar for Ene Uran
0
214
Member Avatar for Mathhax0r

This question, as the title says, is specific to the new file tagging feature in Windows Vista. Basically, I want to make a tag cloud for a certain folder, and in order to do this, I need to access all of the tags of the files in the folder. What …

0
64
Member Avatar for scrace89

I apologize for the childish explanation, but simple concepts should be explained simply. An empty string is a string with no characters in it. Imagine we have a basket of 3 apples. If I take away 2 apples we have 1 apple in the basket. If I take away 1 …

Member Avatar for willygstyle
0
278
Member Avatar for patto78

How about having a dictionary containing volume, brightness, and contrast? [CODE] def adjust(self, PROPERTY): print self.stats[PROPERTY] adjust = raw_input("") while adjust == "+" or adjust == "-": if adjust == "+": self.stats[PROPERTY] += 1 else: self.stats[PROPERTY] -= 1 if self.stats[PROPERTY] < 0: self.stats[PROPERTY] = 0 elif self.stats[PROPERTY] > 20: self.stats[PROPERTY] …

Member Avatar for Mathhax0r
0
72
Member Avatar for stellalxin

I know this is a Python forum and all, but look at the ad under your post. They have a free trial version, so maybe that'll work out for you.

Member Avatar for stellalxin
0
978
Member Avatar for miesnerd

os.listdir(arg) will return a list of all of the names of the files in whatever directory you put in for arg, so that's your first step. Take a look at [url]http://www.python-excel.org/[/url] for the specifics on working with excel spreadsheets. They aren't included with the standard distribution or Python, so you'll …

Member Avatar for Mathhax0r
0
244
Member Avatar for Mathhax0r

I just started learning Python last week, and I was having a few issues with doing a GUI app in Tk. My main problem is this: I have a list (each member of the list is a frame with a picture and some text in it) that populates itself by …

Member Avatar for woooee
0
115

The End.