988 Posted Topics
Re: There is a simplifying wrapper for pygame called gasp. You need pygame installed first for this to work: [code=python]# using module gasp to draw an arc, a box, plots and circles # # info: GASP (Graphics API for Students of Python) # A library built on pygame that enables absolute … | |
Re: I don't think it has much to do with the size of the list, you are simply going past the number of indexed elements. Look at this example: [code=python]my_list = [1, 2, 3, 4] print my_list[4] # IndexError: list index out of range [/code] ![]() | |
Re: Here is an example to make the tk window disappear: [code=python]import Tkinter as tk import tkFileDialog root = tk.Tk() # show file dialog without Tkinter window root.withdraw() filename = tkFileDialog.askopenfilename() print filename [/code]To see the code tags around this code, temporarily click on the "REPLY W/QUOTE" button. | |
Re: You must not have installed tkSnack properly. For instance open the zip file snack2210-py.zip and extract file tkSnack.py to C:\Python24\Lib and the folder snacklib to C:\Python24\tcl | |
Re: If you know you are stupid, then you are not quite as stupid as you thought. | |
Re: Peace on earth for 24 hours. Very unlikely though! | |
Re: Talking about poor churches there is one of the many in my neighborhood: [url]http://www.crystalcathedral.org/visitors/[/url] | |
Re: I am not quite sure what you mean with store, If you mean store in a string, there are these ways: [code=python]a=['city','village','town','capital'] a1=len(a) a2=range(a1) s = "" for x in a2: a3=a[x] print a3 s += a[x] print s # cityvillagetowncapital [/code]Much simpler: [code=python]a=['city','village','town','capital'] s = "" for x in … | |
Re: In your scipy directory there is the package init file __init__.py and there also should be a __config__.py file. If not, you may have to reinstall or run the setup.py program. [code]python setup install [/code] | |
Re: CSV files are generated by spread sheet programs. Rows make a line in the file and the data columns are separated by commas. Python has a module called csv that makes processing this type of file much easier. Check the Python manual. ![]() | |
Re: In a similar vain, I have 678 posts right now and should have 679 after this post. Wow, there is excitement in life after all! | |
Re: [QUOTE=jwenting;526374]Google said so...[/QUOTE]A beautiful come back! You are showing the witty side of yourself there JW. I have friends that work at MS, and they claim that they already have a great search engine in house. Looks like Yahoo might just be market share. | |
Re: We learned that it is only used for function arguments, and ** indicates a dictionary of variable number of key:val arguments. | |
Re: Something like this might do it: [code=python]import random def dela(x): sum=0 mylist = [] while sum < x: b = random.randrange (1, x - sum + 1) mylist.append(b) sum = sum + b #print b, return sum, mylist # test it ... sum, mylist = dela(5) print mylist # eg. … | |
Re: Somewhat repugnant! Do they teach that sort of skill in public school? | |
Re: I don't see any new avatars. Just a couple of old ones that have been adopted. | |
Re: The mild way to deal with Telemarketers is to say: "Just a moment, I will get my mother." Lay the phone on the table and let them wait, waste their time, they will eventually hang up. Wait a minute, that could be a nice new thread. | |
Re: First you have to get the basic design of the deck and the hand of cards down: [code=python]# basic design of a card game using Python import random def show_hand(hand): """give drawn cards more detailed descriptions and then display""" for item in hand: rank = item[0] suit = item[1] if … | |
Re: There are many more visitors that never register. | |
Re: Usually it's from a class that has an overloaded __call_() in it. | |
Re: If you set year=0 and then use range(year+1), you only go once through your loop. | |
Re: Read line 8 and 9, you got to have the properly named icon image file for this to work. | |
Re: I guess whether or not you like a commercial is still a matter of taste. I think commercials make watching TV at least a little interesting. | |
Re: If it's like the like() function in VB, then you can do it with module re, which does have wildcard and characterlist patterns. | |
Re: Did you see vegaseat's post in "Starting Python" about using module pyglet to sound off a series of wave files? See: [url]http://www.daniweb.com/forums/post590403-133.html[/url] | |
Re: [QUOTE=scru;592378]Every three days? Consider yourself lucky and let's leave it at that.[/QUOTE]I agree, my cplusplus eats two rats a day, and I had to move to the inner city so it wouldn't starve! | |
Re: In a nutshell: [code=python]def add(a, b): return a + b var = 2 str = "var = add(2, 3)" # execute the code snippet inside the str string variable exec(str) print var # --> 5 [/code] | |
Re: On top of that I just love pizza from the hut! | |
Re: Your exploration could aid other folks. Just remember that Python style recommends to have class names begin with upper case and function/method names to begin with a lower case letter. | |
Re: Nice code G-Do. I added default dimensions and also added "(wait 2 to 3 minutes to show)" to the title to assist the impatient user. | |
Re: Do you just want to know if they are equal? If that is the case, you can simply use: [code=python]# compare two files and check if they are equal # files can be binary or text based import filecmp # pick two files you want to compare ... file1 = … | |
Re: Now you know why so many folks watch TV because of the commercials rather than the lousy content of the program. | |
Re: Please use code tags around your Python code to preserve the proper indentations. Check the message in the background of the Quick Reply message box for the code tags. | |
Re: If you insist on giving each entry field a recognizable name, you can try this: [code=python]# create named multi entries in Tkinter import Tkinter as tk class MyFrame(tk.Frame): """ entries are in the same grid """ def __init__(self, master): tk.Frame.__init__(self, master) words = ["one","two","three","four","five","six","seven","eight","nine"] # create a list of entries … | |
Re: Give this a try: [code=python]import random data = ["apple", "orange", "melon", "pear"] # this picks one item from the list above print random.choice(data) [/code] | |
Re: Please use code tags to mainain proper Python indentations! [code=python]def my_f(modelfilename): modelfile = open(modelfilename) modelline_list = modelfile.readlines() modelfile.close() itemY = ["lol", "young", "HoLa", "...", "Yum!", ":o)", "blokes", "!!!", "hello"] itemO = ["old", "yes", "Mom", "serious", "blog"] for line in modelline_list: for itemy in itemY: if itemy in line: print "+1 … | |
Re: I think vegaseat had this posted some time ago, read the comments for instructions: [code=python]# Py2Exe version 0.6.3 setup file for console programs. # # If this is a windows GUI application replace the last line with # windows = [{"script": 'myFile.py'}] ) # # Enter the file name of … | |
Re: Give module subprocess a try, it's a bit more advanced: [code=python]import subprocess # execute the code and pipe the result to a string test = "ping xxx.xxx.xxx.xxx" process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE) # give it time to respond process.wait() # optional check (0 --> success) print process.returncode # read the … | |
Re: With Python you can use the slicing operator to help out: [code=pyton]t1 = '1230' # --> 12:30 t2 = '100' # --> 1:00 # slicing operator seq[begin : end : step] # step is optional # defaults are index begin=0, index end=len(seq)-1, step=1 # -begin or -end --> count from … | |
| |
Re: The proof is in the pudding. Take a small project like creating a monthly calendar and try to do it with Java and then with Python. | |
| |
Re: There are 2 versions of Python available than can run from a USB thumbdrive. One is MovablePython and th other PortablePython, the last one is free and the first one cost just a small amount (its older Python24 version is a free download however, so you can evaluate). |
The End.