324 Posted Topics
Re: I always use the @functools.wraps(f) decorator for decorator functions to help with debugging. | |
Re: Why not simply use itertools.islice and a fibonacci generator? | |
Re: Like Dr. Griboullis says, this will work: sentence = "I now have a total of %s yellow bananas!" for i in range(2, 11): print sentence % i | |
Re: Works very well, thank you! | |
Re: A shorter version of the PyGame approach: import pygame as pg try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def play(): pg.mixer.music.play() # pick .wav .ogg .mid or .mp3 music files you have in # the working folder, otherwise give the full file … | |
Re: Check Python module tempfile. | |
Re: Your assumption is correct. Line 29 unpacks the 3 item tuple that is returned to the 3 variables beans, jars, crates You can use a test print to show the return `print secret_formula(start_point)` | |
Re: Eric5 is a great IDE, I use it all the time. Under the Extra tab I like spell checking and the large set of tools. | |
Re: This seems to work: # using the Python Image Library (PIL) to resize an image # works with Python27 and Python32 from PIL import Image import os image_file = "Flowers.jpg" img_org = Image.open(image_file) # get the size of the original image width_org, height_org = img_org.size # set the resizing factor … ![]() | |
Re: One approach would be to create a list of the numeric inputs and then use Python functions min and max to get the result. Here would be a typical example: # create a list of integer/whole number inputs mylist = [] while True: n = int(input("Enter a whole number (-99 … | |
Re: I would use Python 2.7, it has some features of Python 3 built in. | |
Re: When I am hiking in the mountains I carry my mouthharmonica along. ![]() | |
Re: If it only would be that simple! Just fools gold? | |
Re: I reckon the idea was that healthy mothers and their healthy children are good for the future of this country! However, that is not on the agenda of the Koch brothers who supported many of the radical members of congress. They want less taxes! | |
I just read an article in the paper that tech savvy younger folks prefer public transportation, so they can use their time with a notebook computer or tablet, rather than wasting time in a car going to work. How do you get to work? | |
Re: The argument count=0 is the default value in case count is not used, like when you call the function initially. But in your calls inside the recursive function you give count the updated value. | |
Re: Take a look at: http://www.daniweb.com/software-development/python/code/216550/tkinter-to-put-a-gif-image-on-a-canvas-python You have to do the button part. | |
Re: The nice thing about Python is it's friendly syntax when compared to Java or PHP. Also Python is a powerful modular language with many modern programming concepts. | |
Re: You are trying to use a list as a dictionary key. Python list objects are mutable and can not be used as keys. You could change them to tuples. | |
Re: You don't have to import the math module. Follow Scol_R_LEA's advice, it will make your code more orderly and easier to read. It will be easier to get help. | |
Re: See also: http://www.daniweb.com/software-development/python/code/216852/an-image-button-python-and-tk | |
Re: I think I will wait till BMW brings out their electric city car. | |
Re: If you put your exit condition in the while line, then whatever is in the while block of statements will execute during that final loop. | |
Re: You might be able to use the python-twitter module. | |
Re: Looks like lines 6 and 13 are just test prints for your information. Most programmers just comment them out. | |
Re: I agree, passing your variables via self to your class methods will make your life easier. | |
Re: One hint: print(random.sample(range(1000), 100)) This will show you a list of 100 unique random integers with values from 0 to 999. | |
Re: At your level of experience you need to write your code a few lines at a time and run it. Look at the error messages if they come up and correct the code. | |
Re: Store your words in a word:hint dictionary. | |
Re: Numpy is not only fast, but in this case simple to use. | |
Re: I assume your compiler gives you some helpful error messages. | |
Re: You should also start a new thread, instead of hijacking someone else's old threat! | |
Re: Just comment out clrscr(), it is sort of silly to use. Mostly a leftover from the rather outdated Turbo C. | |
Re: We have already spent 2.7 trillion on the wars on Iraq and Afghanistan, why not spent another trillion in Syria to install a radical Moslem government there too. | |
Can anyone give this a try? '''print_error_python33.py there are times when a print() trailing newline disappears with Python 3.3.0 this does not happen with Python 3.2.3 or Python 2.7.3 ''' size = 180000 print("creating long string of %d sevens" % size) # create a long string of digits s2 = … | |
Re: Or use something like this: mixed_numeric_list =['1e3', '+3.14', '-77', '0x123abc', '0b1111'] numeric_list = [eval(n) for n in mixed_numeric_list] print(numeric_list) ''' [1000.0, 3.14, -77, 1194684, 15] ''' | |
Re: Don't use file as a variable name since file() is function in python2 You don't do anything with f | |
Re: I assume you have the module calgraphics. The code example is written poorly and does not assign a namespace. Just hope that Monitor is a class from the module, see if you can find it in the module source code. | |
Re: A couple of extra print statements will help you. IMHO the code is nonsense. | |
Re: How many Software Engineers does it take to change a lightbulb? | |
Re: At this point it would be nice to know what your input data is. And what you expect your output data to look like. |
The End.