988 Posted Topics
| |
Re: If list comprehension or generator expressions are not in your knowledge yet, maybe this is a little easier to understand: [code=python]def first_letters(s): temp = "" for letter in s.split(): temp += letter[0] return temp s = 'Old hero sleeps healthy in Thailand' print first_letters(s) [/code]A little bit more long winded, … | |
Re: I like my own avatar the best! Who is jbennet anyway? Professor SOS's avatar is rather cool though! | |
Re: [QUOTE=jwenting;631990]no, but both Osama and McCain are Marxists...[/QUOTE]I thought that the slogan "There is a Marxist in every bush!" (no pun intended) went out with the nutty Senator from Wisconsin 50 years ago. | |
Re: You might have to give us some more of your code. Don't be bashful! | |
Re: [QUOTE=Lardmeister;661579]Like the dudes hairstyle![/QUOTE]Our phys-ed teacher has exactly this hairstyle! | |
Re: To find all functions/methods in a module like gasp use: [code=python]import gasp print "List the functions within module gasp:" for f in dir(gasp): print f [/code]Look at the output, maybe it's just a minor spelling difference. Info: GASP (Graphics API for Students of Python) is a library built on pygame … | |
| |
Re: Slight variation of ChrisP_Buffalo's suggestion: [code=python]# create number:frequency dictionary num_freq = {} for num in file("floats.txt"): #print num, type(num) # strip trailing new lines num = num.rstrip() num_freq[num] = num_freq.get(num, 0) + 1 #print num_freq print '-'*30 # create sorted list of (freq, number) tuples # high freq first, show … | |
Re: riyadhmehmood, do not hijack somebody elses thread! Very bad manners. Start your own thread. | |
| |
Re: Yes, there is a backspace character '\b', but not all IDEs will have the right output window for it: [code=python]# backspace twice and overwrite with space print '1234567\b\b ' raw_input('press enter') # wait [/code]The standard DOS command window will work. | |
Re: This is one way to produce a syntax error: pint " Hello Cu Python!" or ... Print " Hello Cu Python!" Remember Python is case sensitive. | |
Re: Here is an example of using the Tkinter GUI toolkit to bring up a 5 second splash screen. All the info you want needs to be written into the picture itself, using one of the popular image editing utilities: [code=python]# create a splash screen, 80% of display screen size, centered, … | |
Re: Look at your code, what are your import statements? Usually they are at the start of the program code. | |
Re: I just tried it with my old monitor. I threw it 12 feet and 7 inches. Should be an Olympic event! | |
Re: Something like this should do: [code=python]s = 'xxxxx - xxxxx' space = ' ' nospace = '' s = s.replace(space, nospace) print s # xxxxx-xxxxx [/code] | |
Re: I think you have to write it this way: patternMatching(r"The|fox", 'The little brown fox') | |
Re: [QUOTE=jephthah;633795]LOL but seriously, if there ever was a problem that should be solved by Perl... this is it. look into Perl. this is the kind of problem it's designed to do. and can do it in about 3 lines of code.[/QUOTE]Python does it with one line: [code=python]text = text.replace(' ', … | |
Re: [QUOTE=sittas87;634343]As if Bill's retirement will keep him away from microsoft.He has done a gr8 job to be fair. And as for the charity...supurb!! thats anyways small change for him even though its alot He should give me charity money.lol Good job Billy[/QUOTE]I go along with that! Bill Gates had a … | |
Re: If your paragraphs are properly separated, you could use something lke this: [code=python]text = """\ This is my first paragraph. This is my second paragraph. This is my third paragraph. """ q = text.split('\n\n') print q """ my output --> ['This is my\nfirst paragraph.', 'This is my\nsecond paragraph.', 'This is … | |
Re: I don't think the SND_PURGE flag is meant to work the way you interpreted it. | |
Re: Starting with Python3 the / will be float division and // will be integer division. You can use these future feature already by importing the __future__ module: [code=python]from __future__ import division print "Welcome to SCLMIP(Simple Calculator For Linux Made In Python)" while True: equation = input("Equation: ") print equation if … | |
Re: Well, it gives the religious right and Mr. Schwarzerneger something to do! The economy is going down the tube, but by golly at least the gays can't have a wedding! | |
Re: I wonder what the ecnomics of driving an all electric car are. Electricity is certainly not cheap, close to $0.1 per kwh in LA. Then there is the capital cost of the battery, Lithium Ion would be the best for size and weight, but might add close to $30,000 to … | |
Re: I work in a hospital and patients that suffer from terminal cancer simply don't think like that! This must be a silly hoax. | |
Re: Using raw_input() makes more sense and it is portable across the different OS and editor output windows. | |
| |
Re: Creative writing in the buff does work well, but coding may not. I guess it depends on the program you are working on. | |
Re: Is your dart game just a console game where the location the dart lands is a random pick? | |
Re: [QUOTE=happimani;624259]Dear All, What is the Major Differences between Python 2.3 and 2.4 and What are all the Major Features in Python 2.4?????????? regards Mani[/QUOTE]My understanding is that Python24 introduced a much better parser and is quite a bit faster than Python23. Python25 is the way to go if you can, … | |
Re: Not the easiest thing to do and depends heavily on your OS. Here is a DaniWeb snippet for the Windows OS: [url]http://www.daniweb.com/code/snippet399.html[/url] The wxPython GUI toolkit also offers a printer widget. | |
Re: The wxPyton GUI toolkit has the fancier widgets for animation, graphics, plotting, sound and so on. If you are not at all familiar with GUI programming, Tkinter is a good way to start with and get the hang of it. Tkinter has a lot of sample code. | |
Re: I am curious what operating system you have. I have been trying to install PyQt4 on my Windows Vista machine and it seems to fail. I downloaded PyQt-Py2.5-gpl-4.4.2-1.exe which is the Windows binary installer. It is supposed to contain everything needed for PyQt development except for Python itself: PyQt Qt … | |
Re: My family used to go the end of August and the first part of December for the least crowds. It's expensive, but a lot of fun! | |
Re: You use a while loop like that to exit or stay in the program: [code=python]while True: # ... # you code here # ... sel = raw_input("Enter q to quit, m for more: ").lower() # entering q will break the loop, anything else keeps looping if sel == 'q': break … | |
Re: Try: [code]text_file = open(car_model+".txt", "w") [/code] | |
Re: Almost as good as driving in LA! Actually: [url]http://www.telfazy.com/[/url] has some interesting videos to watch. | |
What Windows Vista program runs the Compiled HTML Help Files (.chm)? Under properties only a meaningless descriptor shows up. | |
Re: You use return: [code=python]def get_color(): color = raw_input("Enter the name of a color: ") # process it color = color.lower() return color pcolor = get_color() print pcolor [/code] | |
Re: LOL, I like to see the teacher's face if jimbox123 turns in slate's code as homework! | |
Re: Converting documents to PDF: [url]http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/[/url] uses The ReportLab Toolkit: [url]http://www.reportlab.org/downloads.html[/url] with images also need the Python Imaging Library (PIL): [url]http://www.pythonware.com/products/pil[/url] The problem is that you have to bring in the MS-Word document into python to process it. If you simply have to convert a MS-Word document, you can bring it … | |
Re: You could bundle your Python program with py2exe and then call that .exe file from your C++ program. | |
Re: Class instances have to be tested differently, since you also have to supply the class info (instance of what?): [code=python] >>> class Test: ... pass ... >>> t = Test() >>> type(t) <type 'instance'> >>> isinstance(t, Test) True >>> [/code]If you use the new style class, this becomes more apparent: … | |
Re: You may have to use class methods __getstate__ and __setstate__ to pickle your type of class correctly. | |
I find those new popup ads from HSBC on DaniWeb very annoying and would in no way become a customer of HSBC. What are these folks thinking? | |
Re: [QUOTE=hammerhead;613620]They are pretty much useless if they do nothing else other than to boost up ones 'hard drive' temporarily.[/QUOTE]If there is nothing on the 'hard drive', no drug will help, not even the usual caffeine (most popular energy drinks), hyper-breathing (oxygen) and tuna diet. | |
Re: If you have a Windows machine you can change the frequency and duration: [code]// simple sounds via Beep(frequency_hrz, duration_ms) // on the PC internal speaker, a Windows Console program #include <stdio.h> #include <windows.h> // WinApi header file int main() { puts("using winAPI Beep(frequency_hrz, duration_ms)..."); Beep(523,500); // 523 hertz (C5) for … |
The End.