No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
19 Posted Topics
A classic of early text-based interfaces... Any way to do it in Python? I tried getch(), but it doesn't really work (for instance, if you hit Enter to confirm a menu selection, and then it goes to a "press any key" thing with getch(), getch() will pick up the Enter … | |
Really, the title says it all. Is there any way to compile all the instances of a class into a list, or other such data structure? | |
Is there any easy, [i]very fast[/i] way to edit image files with Python? Any extension that Windows uses is fine. | |
I know, this is a stupid question, but is it possible for a class to have two variables, one of which has a value, and the other of which will [i]always[/i] hold the same value, unless the user changes it? In essence, making the second variable a duplicate of the … | |
I'm currently working on an application to which sound integration is important. Currently I'm using winsound for all the sound-related aspects of the program, but it is sub-optimal. I've been unable to make it completely work, and .wav files are bulky. Are there any equally usable alternatives to winsound? | |
Re: What you're looking for is collision checking. Off the top of my head, I don't have any examples of it, but a search on 'Python Square Collision Checking' or something like that might turn up an answer. Will the square rotate, or will it always be aligned with the x/y … | |
Sorry to have to post two consecutive questions for other people to help me with, but I'm having a problem with winsound that I simply can't figure out. I've checked all the documentation I could, but there's no answer. The problem is with SND_PURGE. [quote=Python Library Reference]SND_PURGE Stop playing all … | |
It's always bugged me how it seems that the only way to find out where you are inside a for loop is to use a counter. For instance, suppose you want to iterate through a list, and print every entry on a second line, but for the second-to-last entry you … | |
I've been trying to program a "press any key to continue" function, simply because raw_input feels noobish, but so far I haven't been having much luck. I did a search and the opinions are nearly unanimous that getch() is the way to go, but...things haven't gone that well. Here's an … | |
Iterating over a list, possibly deleting elements. It's the bane of my existence. Suppose, for instance, we have a list of numbers, and want to iterate over it and delete each and every odd one. Sounds simple, right? Sorta. It's trivial, but the code you end up with is pretty … | |
Just noticed an odd little problem. Instead of explaining it, take a look at this IDLE run: [code]>>> ================================ RESTART ================================ >>> class test: eggs = True >>> var1 = test() >>> var2 = "text" >>> type(var2) <type 'str'> >>> type(var2) == str True >>> type(var1) <type 'instance'> >>> type(var1) … | |
At various points in my text-based programs, I've had to write a function for use in multiple-choice menus. It needs to have the following qualities: [list][*]Ignores non-number input, repeating the request if it is given a string. [*]Can be given upper and lower limits on the acceptable numbers, repeating the … | |
This is probably totally absurd, but...is it possible to, through Python, access the command line and use it? For instance, write a program that outputted all of the files in a given directory, much like cd [directory] dir would? | |
For instance, if you have the following (random example): [code=Python]w = input("Enter width") h = input("Enter height") for x in range(0,w): for y in range(0,h): print x,y if (raw_input("Stop? y/n") == "y"): break[/code] That would only break out of the y loop. You could introduce another variable, and change the … | |
[quote] cell.health -= fighters[0].compDmg(fighters[0],cell) TypeError: compDmg() takes exactly 2 arguments (3 given)[/quote] Both fighters[0] and cell are object instances. How on earth does it see 3 arguments in this? I don't think wider context is needed, but just ask if it is. | |
There's a function that repeatedly shows up in languages, usually with more or less the following form (Python syntax): [code=Python]var1 = raw_input("Input a number between one and three.") choose var1: case "1": print "You inputted one." case "2": print "You inputted two." case "3": print "You inputted three."[/code] Or something … ![]() | |
Python's system of deciding for you what type to give all your variables is nice and all, but is there a way to force it to give a variable a certain data type? For instance, if you give it the following: [code=Python]n = 2 m = 3 print n/m[/code] It'll … | |
Recently I downloaded Ubuntu v8.04 (Hardy Heron), and was delighted to find Python pre-installed. However, that pleasant surprise was soon dampened by the fact that IDLE would not run, and so I am left without a decent program for coding in Python. gedit works, but lacks pretty much everything except … | |
Hey. I'm working on a simple project that requires a way to find all the empty grid cells accessible along a path that's <= n cells long (an analogy would be TBS movement), and I've got an [i]almost[/i]-working piece of code for it. Here's the function I wrote: [code=Python]def findArea(distance,origin,gridUsed,emptyChar): … |
The End.