851 Posted Topics
| |
Re: What does the _ do in ipstring(_)? | |
Re: Actually some people look better old, of course their is always a face-lift and a tuck here and there. | |
Re: The strip() function only removes leading and trailing characters: [code=python]text = 'goodbye! cruel, harsh world!..?' print text.strip('!,.?') # goodbye! cruel, harsh world [/code]To remove characters all through the text you can use a loop this way: [code=python]text = 'goodbye! cruel, harsh world!..?!' stripped_text = "" for c in text: if … | |
![]() | Re: I think it has to do more with the version of wxPython than Python itself. ![]() |
| |
| |
Re: Here is a good example of the use of [CODE]if __name__ == '__main__':[/CODE] at: [url]http://www.daniweb.com/software-development/python/threads/20774/161504#post161504[/url] | |
Re: Here is a simple oldie: [code]''' example of simple encoding/decoding using rot13 where the alphabet is shifted by 13 positions to 'nopqrstuvwxyzabcdefghijklm' so 'a' becomes 'n' and so on (non-alpha characters are not affected) note: Python2x actually had this built in ''' # here is a way to implement this … | |
Re: Another example: [url]http://www.daniweb.com/software-development/python/threads/191210/868247#post868247[/url] and for multiple items selection: [url]http://www.daniweb.com/software-development/python/threads/191210/886306#post886306[/url] | |
Re: Just a hint: [code]# use module re to find index values import re s = "HHHHHHooooooooooooooooHHHHHHHH" rcp = re.compile("H+") print(s) # index help line print('0123456789'*3) print('-'*30) for item in rcp.findall(s): print item found = re.search(item, s) # span() returns (start, end) end is exclusive print found.span() '''check the hint HHHHHHooooooooooooooooHHHHHHHH … | |
![]() | |
Re: Is the splash screen supposed to be for a console program? | |
Re: People don't smell quite as bad in the gym in the morning. | |
Tuples are immutable objects, they cannot be changed says the Python manual. [code]my_tuple = (1, 2, 3, [4, 5, 6]) # this works my_tuple[3][2] = 7 # clearly the item at index 3 in the tuple has changed print(my_tuple) # (1, 2, 3, [4, 5, 7]) [/code] | |
Re: Without a doubt it is Eli Manning, who could throw a football 80 yards and make it pass though an opening the size of a basketball hoop. | |
Re: Looks like the Brits came up with something worthwhile. The prince picked one fine lass, I must say! | |
Re: Hoax of any kind is probably closer to the truth, but outer space visitors sound so much more like fun! | |
Re: Earthlings have a totally unneeded appendix, did that come from the alien? | |
Re: My friends and I meet in a small café. Serves pretty much only coffee. | |
I am having a problem setting the initial value in the new Tkinter tix module. Can anyone help me out? [code]# explore the tix.ComboBox() # the Tix (Tk Interface Extension) module comes with the # Python27 and Python31+ installation try: import Tix as tix # Python27 except ImportError: import tkinter.tix … | |
Re: You cannot subtract strings, but you can cast them to integers and then it will work. [code]a = raw_input("Enter name: ") b = int(raw_input("Enter the year you were born: ")) c = int(raw_input("Enter the year it is now: ")) print "You,",a,",are ",c - b,"years old." [/code] | |
Re: You can also go through "Projects for the Beginner" right here: [url]http://www.daniweb.com/software-development/python/threads/32007[/url] | |
Re: Permutations of words are actually fun: [code]# permutations using Python module iterools # needs Python26 or higher # itertools.permutations(iterable[, r]) is a generator/iterator import itertools as it word = "rats" # default is len(word) for p in it.permutations(word): # join tuple p to form a string print( p, ''.join(p) ) … | |
Re: Not so fast e-papa! [code]def main(): return 'something' main(2) # TypeError: main() takes no arguments (1 given) [/code] | |
Re: Development time of a fair sized project is usually ten time faster with Python (a high level language) than with C++ ( a low level language). | |
Re: A computer savvy accountant, that sounds like one of those over-bonused Wall street jobs! | |
Re: I am not old enough to drive, but I would love to put this sticker on my car: [B]I Lie To Pollsters[/B] | |
Re: [B]Remember to hold hands and cherish the moment, for someday that person will not be there again.[/B] | |
Re: Catherine Zeta-Jones is stunningly beautiful and talented. | |
![]() | Re: Try to change your print line to: print ("The sum of "+str(a)+" and "+str(b)+" is: "+str(a+b)) or even better: print ("The sum of %s and %s is: %s " % (a, b, (a+b))) Now remember in Python2 input() returns a number and Python3 input() returns a string. In either case … |
| |
Re: It's a tough game despite all the padding, protective gear and helmets. A lot of injured players need replacing. ![]() | |
Re: The overuse of antibiotics will eventually lead to very aggressive super bugs that cannot be treated any longer. | |
This short C# code will calculate the fibonacci number of an integer and display the result in a Windows GUI label. | |
Re: I was almost married twice, but then got scared of the "... till death do us part" thingy! I just enjoy my freedom too much! | |
Re: It has been said that the US president is basically a dictator with a four year term. | |
Re: A simpler way is to convert the list of [english, spanish] lists to a dictionary of english:spanish pairs: [code]def eng2spanish(text, data): ''' takes each word from an english text and prints out the spanish word given in data if the word is not found it prints the default '---' ''' … | |
Re: [QUOTE=Ancient Dragon;1159764]Any time is a good time for pasta :)[/QUOTE]Pasta fagioli, yum, yum! | |
Re: Why does Haskell give such huge executable files? I compiled a simple "Hello world!" program using 'ghc --make hello.hs' and came up with an 'hello.exe' file of over 700 kb! | |
Re: She said, 'For my birthday I want something sporty that goes from 0 to 150 in about 3 seconds.' He bought her a bathroom scale. | |
Re: An elderly man had serious hearing problems for many years. He went to hearing specialist who was able to have him fitted for a set of hearing aids that gave him perfect hearing again. The elderly man went back after a month to see the specialist who asked him, "Is … | |
The End.