Search Results

Showing results 1 to 40 of 368
Search took 0.05 seconds.
Search: Posts Made By: shadwickman ; Forum: Python and child forums
Forum: Python Sep 17th, 2009
Replies: 9
Views: 451
Posted By shadwickman
Python doesn't need to explicity declare variables in the same way languages like C/C++, Java, etc. do. By writing for comment in inComment: you are creating a new variable called 'comment' that is...
Forum: Python Sep 17th, 2009
Replies: 9
Views: 451
Posted By shadwickman
Sneekula's correct. You're storing each item in the inComments like so: (lineNumber, lineText). So you just need to access the correct index of the tuple, the same way you would access an item in a...
Forum: Python Sep 15th, 2009
Replies: 14
Views: 528
Posted By shadwickman
Python is a good choice for easy-going desktop application development. Of course, you're going to want to get adjusted to and familiarized with classes, methods/functions, etc. before starting on...
Forum: Python Sep 2nd, 2009
Replies: 0
Views: 290
Posted By shadwickman
For some reason (this hasn't happened to me in the past), any wxPython scripts I package via py2exe crash on my other Windows computer (lacking a Python install). If I try running it on my other...
Forum: Python Aug 9th, 2009
Replies: 4
Views: 323
Posted By shadwickman
Judging by your first post, when you said "link it to another ..." did you mean pass the values and variables from the first function to the second one?

If you specify what this "previous issue"...
Forum: Python Aug 9th, 2009
Replies: 9
Views: 553
Posted By shadwickman
Well if you install it manually, you need to put it into the C:\Python2X\Lib\site-packages directory in its own folder. Then in that site-packages folder, make a file called chilkat.pth, and in it,...
Forum: Python Aug 9th, 2009
Replies: 2
Views: 209
Posted By shadwickman
If you don't mind as much about memory usage, you could use

if number in range(10, 24): # careful!
# This gives a range of 10 - 23.
# The end index (24) isn't included in it.

if number in...
Forum: Python Aug 2nd, 2009
Replies: 2
Views: 315
Posted By shadwickman
I could give you a full example written for wxPython, but not for Tkinter, sorry :P

But regardless, you'll probably need to use threading for this, as your program will stall until the zip command...
Forum: Python Jul 31st, 2009
Replies: 10
Views: 875
Posted By shadwickman
No offense, but gross code you have there. You have an unbelievable amount that's just copy-pasted. I mean, all the questions are running pretty much the exact same code except for the Q it prints...
Forum: Python Jul 30th, 2009
Replies: 10
Views: 875
Posted By shadwickman
I'm quite sleepy, so excuse me if I'm way off here, but is armRight declared within the global scope of the script? If so, then you need to state global armRight within your function so that when you...
Forum: Python Jul 30th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Oh damn, I forgot, sorry. The list you pass to join should be strings, so it looks a bit messier but you could change that to this:

fh.write(','.join([str(i) for i in [gold, level, ship]]))
...
Forum: Python Jul 30th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Well you've screwed up the try/except thing that I've tried to explain over and over.

You currently have the if statements inside the except block, meaning if there is an error it will print what...
Forum: Python Jul 30th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Well like I was saying, you'd be using pickle for classes and stuff more (or dicts, lists, or tuples).

If you're only wanting to save something like gold, level, ship, then you should only need...
Forum: Python Jul 30th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Then you can just invent some simple format for a file to write that to. Say, the file has the values stored, separated by commas, in a specific order, like:
gold,level,ship,name

So you would...
Forum: Python Jul 30th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
What is it you want to save exactly? This is where classes could come in VERY handy. If you had a player class, and all the stuff you wanted to save were properties of that class (like player.gold,...
Forum: Python Jul 29th, 2009
Replies: 14
Views: 439
Posted By shadwickman
Instead of using a global variable for p, you could just pass that to the function as an optional parameter for the recursion you're doing. And you may want to rename the function. I think that loop...
Forum: Python Jul 29th, 2009
Replies: 13
Views: 982
Posted By shadwickman
For collision detection, tomtetlaw had a similar question, so I'll give you the same answer I gave him. This is for simplistic levels:

Why not try making a black and white image for your level,...
Forum: Python Jul 29th, 2009
Replies: 14
Views: 439
Posted By shadwickman
Bumsfeld is putting you on the right track. I'll say not to convert the raw_input to an integer like you're doing now, so that you can cycle through each character in it as a string. Then just make...
Forum: Python Jul 29th, 2009
Replies: 4
Views: 346
Posted By shadwickman
Flash can take command-line arguments. So you can do os.system("flash.exe myFileToOpen.fla"). That'll open Flash and have it open the document "myFileToOpen.fla".

If the FLA is in a different...
Forum: Python Jul 29th, 2009
Replies: 0
Views: 247
Posted By shadwickman
Hello. I haven't ever needed to bother trying to do things to the console such as clearing one line, changing colours, etc. But now I was wondering if there is a (preferably built-in) cross-platform...
Forum: Python Jul 28th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
You're not understanding: the else with the break is attached to the try/except block. That is inside the while loop. Then, outside the loop, on the starting on the same indentation level as your...
Forum: Python Jul 28th, 2009
Replies: 33
Views: 1,022
Posted By shadwickman
I meant something like this:

I changed the car_list file to make each Car instance's image attribute as a string of the image filename. Like so:

# ...
title = "Golf Mk1 (A1/Typ 17, 1974-1984)"...
Forum: Python Jul 28th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Well if the try ... except block isn't in a while loop, with that else: break segment I posted for you before, then there's your problem.

If you give bad input, it will error and go to the...
Forum: Python Jul 27th, 2009
Replies: 1
Views: 261
Posted By shadwickman
I can tell you've come from C++. You're making things much harder than they need be. Python has such a simple syntax, yet you're clogging it up by doing things similar to how you would in C++.

For...
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
That is due to line 24:

if choice in [1, 2, 3, 4, 5]:

You allow 5 to execute the 'buying-a-ship' if statement instead of the break one. It should just be:

if choice in [1, 2, 3, 4]: # no 5!
Forum: Python Jul 27th, 2009
Replies: 14
Views: 513
Posted By shadwickman
In that case, you could just use filter with a lambda expression :P

mylist = ['apple','orange','mango','pear','strawberry']
target = 'pear'
newlist = filter(lambda x: x == target, mylist)

#...
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Oh... this code looks fairly um, interesting. There are a number of things that should be changed.

It would be best to indent the lines 2- 57 in one level so that they're under the if that...
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Well if you wanted it to re-print your menu every time, you'd just need to stick all those print statements from above that while loop to inside it, right on top of that choice = raw_input... part.
...
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
I can only assume that you put the indentation level of the if statements so that they were inside the loop. They should be outside of that while loop, like I had in my above code.
Forum: Python Jul 27th, 2009
Replies: 33
Views: 1,022
Posted By shadwickman
I hate to spam this thread more than it already has had, but people: PLEASE stop posting when you can still edit your last post. It just clutters things and makes this thread annoyingly unmanageable....
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
This doesn't even incorporate the suggestion I gave, but still contains the unwanted recursion (see lines 12 to 16, along with 27, 30, 38, 41).

You would have to change the Tav function to:

def...
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Huh? Can you post some context (code)? This is it within IDLE for me:

>>> while True:
try:
choice = int(raw_input('Enter Number: '))
except ValueError:
print 'Invalid...
Forum: Python Jul 27th, 2009
Replies: 33
Views: 1,022
Posted By shadwickman
So did you try what it was that I was suggesting then? It seemed logical and I think it would work.
Forum: Python Jul 27th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
Well I'd structure it like this:

# within the function wanting to gather input...
while True:
try:
choice = int(raw_input('Enter Number: '))
except ValueError:
print...
Forum: Python Jul 27th, 2009
Replies: 3
Views: 295
Posted By shadwickman
I can't help with GUI stuff as I can't use Tkinter, only wxPython. However, if you decided to use os system calls, you can always use threading to run the os calls in one thread, and use a second to...
Forum: Python Jul 26th, 2009
Replies: 52
Views: 1,473
Posted By shadwickman
This will lead to strange behaviour and such things due to one problem: the S() function you call to on bad input (adds unwanted recursion). If S is the name of the function that this snippet of code...
Forum: Python Jul 26th, 2009
Replies: 33
Views: 1,022
Posted By shadwickman
Not quite Clueless :P

Haha I just meant this:
You currently (for each car) make the image variable for the Car instance a Tk image thing. Then you append this Car instance onto the car_list...
Forum: Python Jul 26th, 2009
Replies: 33
Views: 1,022
Posted By shadwickman
Instead of appending Tk image instances to the list, try passing the image filenames in the car_list module to the list. Then when you use them in the main script, just create the Tk image instance...
Forum: Python Jul 26th, 2009
Replies: 3
Views: 786
Posted By shadwickman
Yeah, that's definitely a problem. I hope the developers for pyHook release a 2.6 version soon... in the meantime, you can just download the 2.5 source and try re-compiling it yourself for 2.6....
Forum: Python Jul 25th, 2009
Replies: 10
Views: 414
Posted By shadwickman
Oh sorry! I didn't see your previous post metioning that :D Does anyone know if this has to do with Python 3.x? Changing the value of sys.sydout always worked for me...
Showing results 1 to 40 of 368

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC