4,305 Posted Topics
Re: If you want to test what the module bisect suggested by our friend Gribouillis does, run a small program like this ... [code=python]# testing module bisect from bisect import bisect_left costs = [0.0, 2.10, 3.20, 4.70, 4.80] weights = [0, 2, 6, 10] # iterate through a list of possible … | |
Re: You are assuming the word at index in list 'a' makes sense with the word with the same index in list 'b'. Somewhat dangerous. It would be simpler to make a dictionary with a:b (key:value) pairs, this way things that belong together stay together. Also, dictionary searches are highly optimized … | |
Re: Something like this might do ... [code=python]# converted certain variables to strings for testing only data1= [['Contacts', 'company.contacts.count()'], ['Notes', 'company.notes.count()'], ['Met by', ], ['Industry', 'industry'], ['Financial Investors', '31']] data2 = [] for item in data1: #print item, len(item) # for testing if len(item) < 2: item.insert(1, 'missing value') data2.append(item) print … | |
Re: [QUOTE=Ene Uran;683833]If we call folks from Mexico Mexicans and folks from Canada Canadians, what do we call the folks that live in the good old USA? ......[/QUOTE]Yankee Doodles? Good question, since Americans would be inhabitants of the entire American continent. I demand congressional action to clear this up!!! | |
Re: Henri, enjoyed your many posts in the Python section, congratulations on your first kilopost! | |
Re: I think you need to give us just a little bit more information about your code. Mindreading is not everyone's talent. | |
Re: I wouldn't go that way. OGL development and maintenace is pretty well dead. If you are interested in 3D graphics take a look at VPython. | |
Re: If you installed the wxPython docs file, it could be in something like: C:\Python25\Doc\wxPython2.8 Docs and Demos\demo | |
Re: I think at one time you asked about module MD5 to send on a password, you might want to take a look at this post: [url]http://www.daniweb.com/forums/post220840-56.html[/url] | |
Re: You might want to take a peekaboo at: [url]http://www.daniweb.com/forums/showpost.php?p=700777&postcount=147[/url] | |
Re: This pygame sample code at: [url]http://www.daniweb.com/forums/showpost.php?p=700702&postcount=146[/url] might help you. As long as you give the full path name of your image file, I dont think it makes much of a difference in which directory it is. | |
Re: Interesting indeed! Us humble human beings can readily observe matter and energy, but not the state between the two. Let's postulate that 'dark matter' is this flux state, observed only by its gravitational pull. If you believe this, you sleep better at night. It has the soothing effect of a … | |
Re: Ouch, you need to study up on Python basics. A lot of errors in your code. Take a look at the corrected code and figure out where you can improve your coding skills ... [code=python]def main(): print ("This is a program that converts a users first name into it's numerical … | |
Re: Well, if he invented the Blackberry, then he isn't quite as primitive as most people think he is. I would be happy with a portion of good humor and health under my tree. | |
Re: [QUOTE=scru;697472]No, but the ones who want to be perceived as 'creative' use Macs. [I]I use a Mac. That makes me an artist![/I][/QUOTE]I knew you were an artist just from your avatar. | |
Re: Here would be your program using a dictionary ... [code=python]def test(d): for word in d.keys(): count = 0 while True: print "What does", word, "mean?" ans = raw_input("> ") if ans == d[word]: print "Correct!" break else: print "That is incorrect. Try again." count += 1 # ask 3 times … | |
Re: Thank you for making all of the DaniWeb Python users aware of this great article at: [url]http://wso2.org/library/articles/deploying-python-service-axis2[/url] | |
![]() | ![]() |
Re: [QUOTE=Ezzaral;691741]One hour of community service (picking up litter, public land and utilities maintenance and improvements, etc) per spam email sent. 1,000,000 emails sent, mandatory 12 hour work day imposed = 228 years labor. Sounds reasonable to me.[/QUOTE]I go along with that! | |
Re: while you are at the site take look at the do and don't pics, the comments are a stitch | |
Re: Try app.MainLoop() Also OnInit should return a boolean value, usually True | |
Re: If you talk about visitors from outer space, I would say 'no', since distances are simply too far. It would take thousands of years of travel in even the best case. If you talk about loonies, dopers and drunkards seeing something strange, then I would say 'of course!' | |
Re: This is a very good introduction to the Python language with lots of example code: Learning Python, by Mark Lutz and David Ascher. Published by O'Reilly. | |
Re: Along the line of your problems, I have taken the liberty to code a small example that should help you, see: [url]http://www.daniweb.com/forums/post680387-73.html[/url] | |
Re: So it's oil again, worth bombing any country into submission, even Russia? | |
Re: [QUOTE=serfurj]i didn't know that. are you sure??[/QUOTE] It's called Py2Exe and it is a free download like most of the Python goodies. | |
Re: help("modules") hangs up on bad or modified modules or mixed versions, but lets you know! Works well on virgin installations. I have so many modules installed and screw around with them all the time. So I use help("modules") to flush out the bad stuff. | |
Re: I understand that most of those Nigerian dead friend/relative scams originate from the Netherlands and the perpetrators are mostly Romanian Gypsy gangs. | |
Re: Ene Uran left an example of a screen image grabber in the Python snippets: [url]http://www.daniweb.com/code/snippet707.html[/url] She simply used a small for loop to create a delay long enough to sort things out. | |
Re: Python and some of the standard GUI toolkits themselves do not have a builtin method to display FITS images (they are simply too specialized), but I am sure one of the external scientific modules that handle astronmoy will do just that. I know the PyFITS module will (NASA/Goddard Space Flight … | |
Re: I have to admit, this is a clever problem. With a little thought it shouldn't stomp anybody. Here are some hints ... [code=python]# assume you have the following text = """\ My name is OUR_HERO, or simply OUR_HERO, somtimes OUR_HERO. You, my dear friend, can call me OUR_HERO. """ keyword_list … | |
Re: One way to do this ... [code=python]def extract(text, sub1, sub2): """ extract a substring from text between first occurances of substrings sub1 and sub2 """ return text.split(sub1, 1)[-1].split(sub2, 1)[0] # read the data from the file as one string data = """\ #BEGIN 1 1 .1 .2 2 .8 .3 … | |
Re: Which version of the Netbeans IDE did you download for Python coding? Jython allows Python to use the Jave library and feeds into Java byte code. Iron Python, I think, does a similar thing with C# There is also python-like Boo that feeds into the .NET C# compiler. See: [url]http://www.daniweb.com/code/snippet429.html[/url] … | |
Re: In addition to Zetlin's nice explanation, tuples are used in passing arguments to and from functions ... [code=pyhon]def myfunction(a, b, c): d = 2 * a e = b + 5 f = c - 1 return d, e, f a = 1 b = 2 c = 3 mytuple … | |
Re: Nobody is falling off, so it must be flat! :) | |
Re: Something like ... [code=python]from Tkinter import * fenetre = Tk() portee = IntVar() def effacer(): rb1.deselect() rb2.deselect() rb1 = Radiobutton(fenetre, text="HOT 1/2", font=("Times",-15,'bold'), variable=portee, value=4000) rb1.grid(row=4, column=1, sticky = E) rb2 = Radiobutton(fenetre, text="HOT 3", font=("Times",-15,'bold'), variable=portee, value=3850) rb2.grid(row=4, column=2, sticky = E) # preset rb2 portee.set(3850) bt1 = Button(fenetre, … | |
Re: Maybe you are looking for this ... [code=python]def del_text(): """ delete text in enter1 from index first to index last if index last is omitted delete just one character at index first entry1.delete(first, last=None) """ enter1.delete(0, END) # del all text [/code] | |
This post by [B]s7plc[/B] was moved from the Starting wxPython (GUI code) thread ... [QUOTE]I've been working with various widgets from the wxPython demo library, and am making pretty good progress. But I just ran into a problem that I am sure has a simple answer, but I just can't … | |
Re: [QUOTE=scru;665318]Does it loop? Does that mean that when it gets past Generation Z it becomes Generation A? :P I have an opinion about the "Baby Boomers", but you said don't be bashful...[/QUOTE]No, it's like a spreadsheet, it goes Generation Z, Generation AA, Generation AB, ... :) | |
Re: Be aware that your file extension may not always be .txt, but also could be be .TXT or .tXt or txT or such. To get a full count of all of these mixed case extensions it is best to use module glob ... [code=python]# to also count mixed case file … | |
Re: Welcome to the DaniWeb Python forum! Make sure you read some of the posts in "Starting Python" [url]http://www.daniweb.com/forums/thread20774.html[/url] After you read post #4 ( [url]http://www.daniweb.com/forums/post104865-4.html[/url] ), you might recognize that your program can be simplified to ... [code=python]print raw_input("Enter string to be reversed: ")[::-1] raw_input("Press any key to quit") [/code]Sorry, … | |
Re: Putting in a temporary test print line might just help you better understand what is going on ... [code=python]def bubble_sort(list1): # make true copy of list1 so there is no feedback list1 = list(list1) for i in xrange(len(list1) - 1, 0, -1): print list1 # a test print for j … | |
Re: Here is an example ... [code=python]# PyGame example of how to change the mouse cursor import pygame as pg bgcolor = 255, 255, 255 # white screen = pg.display.set_mode((600, 300)) pg.display.set_caption('testing a different cursor') screen.fill(bgcolor) # set the mouse cursor # you can replace diamond with arrow, ball, broken_x, tri_left, … | |
Re: Eliza was the original fake AI program, sounds like Sally will be something similar. Take a look at: [url]http://en.wikipedia.org/wiki/ELIZA[/url] I would favor a program that looks at certain keywords and picks a snappy comeback from a list. |
The End.