Forum: Python 1 Day Ago |
| Replies: 2 Views: 82 What are you asking for help with? |
Forum: Python 1 Day Ago |
| Replies: 3 Views: 117 Better yet: I'll give you about 57,900 examples (http://tinyurl.com/ydd96ld) |
Forum: Python 1 Day Ago |
| Replies: 4 Views: 132 Type your python command (*if you haven't set it up you'll need to use the full pathname to python.exe or pythonw.exe), then the name of your script, then the command line arguments... here's an... |
Forum: Python 2 Days Ago |
| Replies: 7 Views: 149 This is the section he's referring to:
def main():
filename=raw_input ("Gimme a picture.")
n=raw_input ("How many times would you like it tiled?")
img=Image.open(filename)
... |
Forum: Python 2 Days Ago |
| Replies: 3 Views: 115 You have a number of issues in your code revolving around scope.
Here are the first few that jumped out at me:
1) In your dig_sum function, you refer to i but never define it (in your while... |
Forum: Python 2 Days Ago |
| Replies: 7 Views: 149 Welcome to the forums.
EDIT: OP Updated post with Code tags
Also, when asking about a specific error you get, it would help if we could see the entire traceback (which helps to identify exactly... |
Forum: Python 2 Days Ago |
| Replies: 2 Views: 134 When performing an import * in Python, you as a developer actually have power over what is included in that "import all" statement. By populating your package with either an __all__.py file or an... |
Forum: Python 6 Days Ago |
| Replies: 2 Views: 152 With the limited information that you've provided my only guess would be that your Python installation is corrupted. You should reinstall. |
Forum: Python 7 Days Ago |
| Replies: 2 Views: 156 When you return an object it isn't just automagically added to the current namespace... you need to actually store it in something.
All you'll need to do is say graph = plot_it(...), savvy? |
Forum: Python 7 Days Ago |
| Replies: 11 Views: 360 Yes, but be forewarned it's psuedo-private. You can still see and access the variable, it's just obfuscated with the Class name. Look:
>>> class Cpriv(object):
... def __init__(self):
... ... |
Forum: Python 7 Days Ago |
| Replies: 3 Views: 160 A dictionary. The key is the number, the value is the function.
Generate random number, then do something like my_function_dict[my_random_number](). Get it?
EDIT: To illustrate:
>>> def... |
Forum: Python 7 Days Ago |
| Replies: 4 Views: 141 What is that? What are you doing?
EDIT: Also remember that dict is a reserved word in Python I suggest that you change the name |
Forum: Python 7 Days Ago |
| Replies: 4 Views: 158 How about print ' || '.join([each.string for each in tag])... I've never used BeatifulSoup so I don't know about the whole tag.string thing that you're doing... |
Forum: Python 7 Days Ago |
| Replies: 4 Views: 158 Try inserting a print tag trace statement right before the for loop to make sure all elements in tag are actually strings... |
Forum: Python 7 Days Ago |
| Replies: 6 Views: 150 You would use chmod with the target being the directory
That or simply login as root before executing the script. |
Forum: Python 7 Days Ago |
| Replies: 6 Views: 150 Ok, so it's most likely that the folder you're trying to open the file in doesn't have write permissions for the user that is running the python script. You could either run the script as root or... |
Forum: Python 7 Days Ago |
| Replies: 6 Views: 150 What platform is this? Windows XP, Ubuntu Linux, Mac OSX, etc?
There's a number of possibilities here. Most likely the folder you're working in doesn't give you write permissions. |
Forum: Python 7 Days Ago |
| Replies: 7 Views: 184 What functions?
The first code is not working because you're not iterating over your input anymore.
The second code is not working because your indentation is royally screwed up. Everything... |
Forum: Python 8 Days Ago |
| Replies: 7 Views: 184 Unless your teacher is specifically telling you to use them in this manner, you really don't. And if he/she is, then I feel bad for you because your teacher is a terrible programmer.
If you're... |
Forum: Python 8 Days Ago |
| Replies: 3 Views: 180 In the future, please use code tags when posting code. It will allow the forum members here to read your post easily and will give you answers quicker (and of better quality). To use code tags... |
Forum: Python 8 Days Ago |
| Replies: 7 Views: 184 My first suggestion is to remove the giant try/except block. If you make a syntax error your program will quit and never tell you the reason why. That is extremely poor Python coding and opens the... |
Forum: Python 9 Days Ago |
| Replies: 2 Views: 186 I'd look into beautifulsoup if you're looking to break this thing down into an object hierarchy type structure. I haven't used it much, but I know there's plenty of examples on this site of how to... |
Forum: Python 9 Days Ago |
| Replies: 1 Views: 156 The method os.getcwd() can only ever return a single string. There's ever only one current working directory, so when you're saying for d in os.getcwd(), you're actually iterating over the string... |
Forum: Python 10 Days Ago |
| Replies: 2 Views: 142 Something like this perhaps:
for idx_i, each_sublist in enumerate(main_object):
for idx_j, each_string in enumerate(each_sublist):
if each_string == my_letter:
print... |
Forum: Python 10 Days Ago |
| Replies: 4 Views: 143 If you search the forum you'll see this question has been asked a bajillion times.
Here's an example from earlier today (http://www.daniweb.com/forums/post1041001.html#post1041001). |
Forum: Python 10 Days Ago |
| Replies: 3 Views: 156 Just a minor logic error. This should be:
if player[0] != "r" and player[0] != "p" and player[0] != "s":
print "incorrect choice entered" |
Forum: Python 10 Days Ago |
| Replies: 14 Views: 471 Okay... how about this:
>>> data_dict = {
... '1234': ['Matt', '2.5', 'CS'],
... '1000': ['John', '4.0', 'Music'],
... '1023': ['Aaron', '3.1', 'PreMed'],
... '1001': ['Paul', '3.9',... |
Forum: Python 10 Days Ago |
| Replies: 8 Views: 231 Because a string is an iterable object. When using the list() method, it converts any such object to a list by iterating over it. Example:
>>> list( (1,2,3,4,5) )
[1, 2, 3, 4, 5]
>>> list( 'Hi... |
Forum: Python 10 Days Ago |
| Replies: 14 Views: 471 Is this what you mean?
>>> my_dict = {'a':1, 'b':2, 'c':3}
>>> my_dict.keys()
['a', 'c', 'b']
>>> my_dict.values()
[1, 3, 2]
>>> |
Forum: Python 10 Days Ago |
| Replies: 8 Views: 231 Why, yes! This case would be a good one to use the dictionary's get method, which will allow you to determine if the key is already in the dictionary or not, and act accordingly.
def... |
Forum: Python 10 Days Ago |
| Replies: 2 Views: 194 The function readlines() already gives you an "array" (it's list in Python). So I guess that part's solved :icon_lol:
Welcome to the forum Linky. Please, in the future use code tags (or any... |
Forum: Python 11 Days Ago |
| Replies: 12 Views: 358 If I'm not mistaken \b means "backspace". So in this example you're writing a seven digit numeral to the screen with %07d and then seven "backspaces" to clear those numerals before writing the next... |
Forum: Python 11 Days Ago |
| Replies: 3 Views: 153 You can stop using IDLE and just run your code in the console, which retains the usage of Ctrl+C (I believe that IDLE tries to catch Ctrl+C) |
Forum: Python 11 Days Ago |
| Replies: 18 Views: 341 Here's an indexing example:
>>> mydata = [0.0] * 5
>>> mydata
[0.0, 0.0, 0.0, 0.0, 0.0]
>>> mydata[2] = 45
>>> mydata
[0.0, 0.0, 45, 0.0, 0.0]
>>> mydata[0] = 1.0
>>> mydata |
Forum: Python 11 Days Ago |
| Replies: 18 Views: 341 Yes, but when you're inserting to an index, that index must exist. Index 2 does not exist in a single element list (only index 0 and index 1). When you insert, you're also extending your list by... |
Forum: Python 11 Days Ago |
| Replies: 18 Views: 341 Why don't you just fire up your interpreter and see what's happening:
>>> mydata = [0.0]
>>> mydata
[0.0]
>>> # mydata only has one element
>>> mydata = [0.0] * 5
>>> mydata
[0.0, 0.0, 0.0,... |
Forum: Python 11 Days Ago |
| Replies: 12 Views: 358 To overwrite the previous output you could use the system command os.system('cls') on Windows or os.system('clear') on Linux.
But if you're looking for single character control you'll need to look... |
Forum: Python 11 Days Ago |
| Replies: 2 Views: 171 Yes. But the answer depends on your platform. In windows you can use the command-line COLOR command. Here's how:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.... |
Forum: Python 12 Days Ago |
| Replies: 4 Views: 226 You have a lot of options. If you're looking to purely look at html you can use urllib2, or if you'd rather have the module parse out all the elements for you and give you purely the text data you'd... |
Forum: Python 12 Days Ago |
| Replies: 18 Views: 341 Create an empty list:
my_list = []
Create a list of specified length with all "blank" values:
my_list = [''] * my_length |