Forum: Python Jul 27th, 2009 |
| Replies: 52 Views: 1,416 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 21st, 2009 |
| Replies: 41 Views: 1,052 Remember that the script executes downwards; it doesn't all happen at once. Things like raw_input also stall until input is given, then the script continues. So this is fairly easy to do; here's an... |
Forum: Python Jul 2nd, 2009 |
| Replies: 195 Views: 86,316 For Python 2.x:
People seem to overlook the usefulness of built-in functions for handling common issues with lists. A lot of times, filter, map, and reduce can easily and efficiently serve typical... |
Forum: Python Jun 29th, 2009 |
| Replies: 8 Views: 418 You can try the built-in filter function. Here's what I tried in the interpreter:
>>> a = [
'filter',
'lol',
'filter',
'lol',
'lol',
'filter',
'lol' |
Forum: Python Jun 29th, 2009 |
| Replies: 3 Views: 237 Yield is for generator functions. Return ends the function and sends back the specified value.
Generators are functions that return iterators, i.e. they 'yield' a value after each iteration of them,... |
Forum: Python Jun 25th, 2009 |
| Replies: 3 Views: 256 PLEASE! Use tags! If you look at your post, you realize your Python code has no indentation anymore, and indentation is a crucial part of Python. I'm not going to bother looking through your code... |
Forum: Python Jun 25th, 2009 |
| Replies: 4 Views: 720 In case you didn't notice, your linedata dictionary has no key "id". Hence you receiving the "KeyError" problem. You need the ID of the column you're inserting this into if I'm correct (I barely... |
Forum: Python Jun 24th, 2009 |
| Replies: 2 Views: 224 Got it :D
data = [['4/18/94', '29.125', '442.46'],
['4/19/94', '29.336', '442.54'],
['1/20/04', '75.175', '1138.77'],
['1/21/04', '75.711', '1147.62'],
['1/22/04', '75.595',... |
Forum: Python Jun 24th, 2009 |
| Replies: 7 Views: 342 Which Linux distro are you using? Regardless, if you want a visual editor for wxPython, I'd suggest wxGlade (http://wxglade.sourceforge.net/). It generates nice code but it may take a little getting... |
Forum: Python Jun 22nd, 2009 |
| Replies: 2 Views: 290 Your "items" dictionary doesn't have a key named "o" which apparently you are trying to locate. The line if p.weapon == items[sitem[1]] is basically equating to if p.weapon == items["o"]. That seems... |
Forum: Python Jun 21st, 2009 |
| Replies: 7 Views: 316 I haven't done this in forever, and I'm not on a linux machine at the moment, but I'll try to say what I remembered doing :P
If you originally installed it using "sudo apt-get install ...." then... |
Forum: Python Jun 8th, 2009 |
| Replies: 9 Views: 356 All it does is split the input into a list and save it as b like we did before. As of then, we have a list of numbers, but they are actually strings (e.g. ['3', '4', '10']).
From there, we use a... |
Forum: Python Apr 28th, 2009 |
| Replies: 2 Views: 252 I'm highly confused... so what are you asking to call? Assuming you have the attributes __employee_name and __employee_number on the class this function is a part of, this should run fine...
So I'm... |
Forum: Python Mar 27th, 2009 |
| Replies: 2 Views: 1,083 I would say you could take the input string, and split it at each whitespace into a list. Index 0 would be the function name, and each index after would be the arguments. Like:
cmdlist =... |
Forum: Python Mar 26th, 2009 |
| Replies: 15 Views: 1,500 The variable timesflipped used for the while loop is undefined before the comparison while timesflipped < 100:. This script should just return a NameError and not run.
Here's a fixed version:
... |
Forum: Python Mar 25th, 2009 |
| Replies: 2 Views: 291 Why not keep a list of lists for responses corresponding to each user answer? Such as:
responses = [
["Q1, A", "Q1, B", "Q1, C" ],
["Q2, A", "Q2, B", "Q2, C" ],
["Q3, A", "Q3, B",... |
Forum: Python Nov 3rd, 2008 |
| Replies: 2 Views: 374 All I was able to find was this article, but from what it says, it sounds risky as each platform/distro is quite different and difficult.... |