988 Posted Topics

Member Avatar for The Dude
Member Avatar for Hogg

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, …

Member Avatar for Hogg
0
6K
Member Avatar for Ancient Dragon

I like my own avatar the best! Who is jbennet anyway? Professor SOS's avatar is rather cool though!

Member Avatar for peter_budo
0
217
Member Avatar for Aia

[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.

Member Avatar for Aia
0
761
Member Avatar for TheOneElectroni
Member Avatar for TheOneElectroni
0
450
Member Avatar for The Dude

[QUOTE=Lardmeister;661579]Like the dudes hairstyle![/QUOTE]Our phys-ed teacher has exactly this hairstyle!

Member Avatar for Ene Uran
0
68
Member Avatar for mindmesh

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 …

Member Avatar for pyromjm
0
164
Member Avatar for The Dude
Member Avatar for Lardmeister
1
59
Member Avatar for loken
Member Avatar for Ancient Dragon
Member Avatar for fmv2011

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 …

Member Avatar for Ene Uran
0
371
Member Avatar for MikeyFTW
Member Avatar for MikeyFTW
0
1K
Member Avatar for The Dude
Member Avatar for bloody_ninja
0
78
Member Avatar for Matt Tacular

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.

Member Avatar for mchen10
0
474
Member Avatar for adarshcu

This is one way to produce a syntax error: pint " Hello Cu Python!" or ... Print " Hello Cu Python!" Remember Python is case sensitive.

Member Avatar for adarshcu
0
130
Member Avatar for MikeyFTW

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, …

Member Avatar for MikeyFTW
0
10K
Member Avatar for devstudio.2007

Look at your code, what are your import statements? Usually they are at the start of the program code.

Member Avatar for Ene Uran
0
122
Member Avatar for The Dude

I just tried it with my old monitor. I threw it 12 feet and 7 inches. Should be an Olympic event!

Member Avatar for sittas87
1
118
Member Avatar for dinilkarun

Something like this should do: [code=python]s = 'xxxxx - xxxxx' space = ' ' nospace = '' s = s.replace(space, nospace) print s # xxxxx-xxxxx [/code]

Member Avatar for dinilkarun
0
235
Member Avatar for Fuse

I think you have to write it this way: patternMatching(r"The|fox", 'The little brown fox')

Member Avatar for paddy3118
0
138
Member Avatar for sivakrishna

[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(' ', …

Member Avatar for dwks
-2
168
Member Avatar for PcPro12

[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 …

Member Avatar for Ene Uran
-1
155
Member Avatar for mengqing

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 …

Member Avatar for bvdet
0
107
Member Avatar for FreezeBlink
Member Avatar for Ene Uran
0
523
Member Avatar for Chris9999

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 …

Member Avatar for Ene Uran
0
84
Member Avatar for GrimJack

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!

Member Avatar for Ancient Dragon
0
71
Member Avatar for itdupuis

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 …

Member Avatar for Ene Uran
0
159
Member Avatar for The Dude

I work in a hospital and patients that suffer from terminal cancer simply don't think like that! This must be a silly hoax.

Member Avatar for R0bb0b
0
382
Member Avatar for FreezeBlink

Using raw_input() makes more sense and it is portable across the different OS and editor output windows.

Member Avatar for FreezeBlink
0
190
Member Avatar for The Dude
Member Avatar for joshmo

Creative writing in the buff does work well, but coding may not. I guess it depends on the program you are working on.

Member Avatar for 0named
0
355
Member Avatar for Patrick1991

Is your dart game just a console game where the location the dart lands is a random pick?

Member Avatar for Patrick1991
0
119
Member Avatar for happimani

[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, …

Member Avatar for paddy3118
0
142
Member Avatar for lllllIllIlllI

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.

Member Avatar for Ene Uran
0
93
Member Avatar for lllllIllIlllI

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.

Member Avatar for lllllIllIlllI
0
549
Member Avatar for dangermini

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 …

Member Avatar for woooee
0
4K
Member Avatar for The Dude

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!

Member Avatar for maydhyam
0
111
Member Avatar for JA5ONS

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 …

Member Avatar for lllllIllIlllI
0
151
Member Avatar for JA5ONS
Member Avatar for The Dude

Almost as good as driving in LA! Actually: [url]http://www.telfazy.com/[/url] has some interesting videos to watch.

Member Avatar for Ene Uran
0
38
Member Avatar for Ene Uran

What Windows Vista program runs the Compiled HTML Help Files (.chm)? Under properties only a meaningless descriptor shows up.

Member Avatar for Ene Uran
0
247
Member Avatar for mruane

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]

Member Avatar for slate
0
299
Member Avatar for jimbox123

LOL, I like to see the teacher's face if jimbox123 turns in slate's code as homework!

Member Avatar for vegaseat
0
1K
Member Avatar for dinilkarun

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 …

Member Avatar for Ene Uran
0
115
Member Avatar for gReaen

You could bundle your Python program with py2exe and then call that .exe file from your C++ program.

Member Avatar for Ene Uran
0
54
Member Avatar for FreezeBlink

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: …

Member Avatar for Ene Uran
0
264
Member Avatar for i_saw_some

You may have to use class methods __getstate__ and __setstate__ to pickle your type of class correctly.

Member Avatar for Ene Uran
0
116
Member Avatar for Ene Uran

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?

Member Avatar for Dani
0
160
Member Avatar for Salem

[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.

Member Avatar for bumsfeld
0
141
Member Avatar for Diode

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 …

Member Avatar for jephthah
0
9K

The End.