4,305 Posted Topics

Member Avatar for iLikeSunshine

For testing purposes I would write it like this ... [code=python]class Man(object): def __init__(self, name): self.name = name def sit(self): print " is now sitting on bench" class Bench(object): def __init__(self): self.occupants = [] def accomodate(self, person): self.occupants.append(person) print person.name + " now accomodated" def listOccupants(self): for i in range(0, …

Member Avatar for iLikeSunshine
0
74
Member Avatar for eyewirejets

I generally find it easier to use an endless while loop and break out: [code=python]# set up an endless loop ... while True: print "Please use W or L to input the results of the game" print win_loss_code = raw_input('Enter W for Win or L for Loss: ') win_loss_code = …

Member Avatar for jrcagle
0
118
Member Avatar for apollo1492

Replace the commas by plus. What do you expect the user to enter? You may want to give some kind of a templet/hint in your prompt.

Member Avatar for yilmazhuseyin
0
100
Member Avatar for Hugers
Member Avatar for drew7py

BearofNH is right the correct usage is ... [code=python]import numpy qq = [1, 2, 3] ar = numpy.array(qq, dtype='f') print(ar) # [ 1. 2. 3.] [/code]It is always easy to run a little test program. It might also be easier to use something like this ... [code=python]qq = [x for …

Member Avatar for Ene Uran
0
3K
Member Avatar for Ancient Dragon

The tomatoes and onions on there should be relatively healthy. I love my Fatburger Turkeyburger! [url]http://www.fatburger.com/menu/[/url]

Member Avatar for Ene Uran
0
40
Member Avatar for mruane

If it is a something like a mutliple choice quiz, you can organize all the questions/answers into a list of tuples. Each tuple might have this order: (question, answer1, answer2, answer3, answer4, answer_code) Each of these tuples comes from a data file were each question looks like this: question answer1 …

Member Avatar for mruane
0
148
Member Avatar for leegeorg07

Strange that Ulipad does this, I find my installation very stable. There is Komodo Edit 5.0, but this free version does not come with the debugger. You could install a good external debugger like winpdb to use with it. Then there is Editra, however it is still in it's alpha …

Member Avatar for leegeorg07
0
78
Member Avatar for jculverwell

The function s.strip() will do ... [code=python]s = repr("callbackfunctionname({'Last': 'Doe', 'First': 'John'})") print s # remove leading and trailing character '"' print(s.strip('"')) """ my output --> "callbackfunctionname({'Last': 'Doe', 'First': 'John'})" callbackfunctionname({'Last': 'Doe', 'First': 'John'}) """ [/code]

Member Avatar for jculverwell
0
181
Member Avatar for eyewirejets

The rule is that you need to define your function before you call it. The rule relaxes if you call one function from another function. Generally line up your imports, then your classes, and then your functions before you go at them.

Member Avatar for Stefano Mtangoo
0
85
Member Avatar for wheatontrue

You can use a list comprehension to speed things up ... [code=python]# create a list of indexes for spaces in a text text = "According to Sigmund Freud fuenf comes between fear and sex." space_ix = [ix for ix, c in enumerate(text) if c == " "] print(space_ix) # [9, …

Member Avatar for wheatontrue
0
142
Member Avatar for abczxy124
Member Avatar for serkan sendur
Member Avatar for Nick Evan
0
140
Member Avatar for jaysonperry22

There is an indentation problem with one of the def statements. You are asking for total_hours twice and should ask for hourly_pay at least once. You need to pass the required arguments from and to the functions.

Member Avatar for vegaseat
0
129
Member Avatar for drew7py

You could convert the list to a string and use slice ... [code=python]q = [23, 'CL', '006', '2004', 'DBA8ORPU', '41', '8Y', 'S0111P', '2'] # slice off first and last character str_q = str(q)[1 : -1] print(str_q) """ my result --> 23, 'CL', '006', '2004', 'DBA8ORPU', '41', '8Y', 'S0111P', '2' """ …

Member Avatar for drew7py
0
17K
Member Avatar for ithelp

[QUOTE=Ancient Dragon;794114]people will show up with either credit or debit cards instead of money. Its almost that way now -- probably 3/4 my sales are with credit/debit cards. When I was first married in 1962 a pickup full of groceries would cost about $65.00 USD. Today I can't get just …

Member Avatar for ithelp
0
212
Member Avatar for leegeorg07
Re: ides

I still like to use DrPython, but you need to instal the wxPython GUI toolkit first (something you should have anyway). DrPython has some neat downloadable plugins like 'codehelp' and 'run from buffer'. Simply extract the zip file into your Python folder. You can download it from: (Windows and Linux …

Member Avatar for leegeorg07
0
111
Member Avatar for kiddo39

We help those who show a little effort at first. Hint, convert x to a string and iterate the string summing up the int value of each character.

Member Avatar for kiddo39
0
67
Member Avatar for scru

Rashakil Fol's approach shaves off a few precious fractional microseconds ... [code=python]# calculate the luminance of a color pixel # (psyco does not help to improve speed) def luminance1(pixel): """calculate and return the luminance of a denary pixel value""" r = pixel & 255 g = (pixel & (255 << …

Member Avatar for vegaseat
0
153
Member Avatar for kiddo39

Don't give up, just keep going ... [code=python]s = "1#%$^5hbg458#$54bjyfuig324ghal&%90a11y$#6ty7" str_digits = ''.join([c for c in s if c.isdigit()]) str_nodigits = ''.join([c for c in s if not c.isdigit()]) str_comp = ''.join([c for c in str_digits if int(c) in (4,6,8,9)]) str_prime = ''.join([c for c in str_digits if int(c) in …

Member Avatar for kiddo39
0
127
Member Avatar for Jaycee

I like C# in Windows Applications, and find the flow of the code much easier to follow than that of the corresponding C++ code . Some folks say that C# is a mix of Java and C++. I think of it as Delphi in a classy C++ coat, with the …

Member Avatar for LizR
0
260
Member Avatar for gabec94

1) Compare the break indentation in p1move() to p2move() also keep your indentation levels uniform 2) [B]elif p1move1 != 'a' or 'b' or 'c' or 'd' or 'e' or 'f' or 'g':[/B] should be [B]elif p1move1 not in 'abcdefg':[/B] 3) There is a lot of unneeded code 4) All those …

Member Avatar for lllllIllIlllI
0
138
Member Avatar for Stefano Mtangoo

Portable Python from: [url]http://www.portablepython.com/[/url] Makes Python25 portable enough to run from a small USB flash drive. It comes with the very capable editor SciTE.exe preconfigured to run on portable Python. Simply run your Python code from SciTE (press the F5 key). You can plug this USB flash drive into any …

Member Avatar for Stefano Mtangoo
0
393
Member Avatar for Ghostenshell

What do you expect this dictionary to look like? Let's say muns = ['41', '82', '2', '61', '7', '33', ...]

Member Avatar for woooee
0
157
Member Avatar for chound

The .NET Framework combines a number of languages. If you want to create Windows GUI programs, C# would be the choice. I parked a number of Csharp snippets on DaniWeb, click the Code Snippets on the top of this page. Look the short code samples over, and see if you …

Member Avatar for Salem
0
639
Member Avatar for mrpoate

The Tkinter widget Label has a default border width of 2, so use bd=0 like shown here: heading = tk.Label(self.heading_frame, image=savvy_bar1, bd=0)

Member Avatar for mrpoate
0
135
Member Avatar for Salem
Member Avatar for Aia
0
71
Member Avatar for Ghostenshell

Function calls are time expensive in Python, so I modified Sneekula's count_char2() approach by replacing all those calls to islower(), isupper(), isdigit() and isspace(), and also changing the order of if/elif to use the most common character test first. The result is promising ... [code=python] # timing character count by …

Member Avatar for Stefano Mtangoo
0
972
Member Avatar for Luckymeera

If you are using the wxPython GUI toolkit, I can help you. Take a cursory look at: [url]http://www.daniweb.com/forums/showpost.php?p=777681&postcount=104[/url] I am not certain if Tkinter has anything available to do that kind of thing.

Member Avatar for vegaseat
0
123
Member Avatar for revenge2

The {0} is new in Python30 and indexes a formatted print()... [code=python]print("the {0} goes {1}!".format("dog", "woof")) # the dog goes woof! print("{1} goes the {0}!".format("dog", "woof")) # woof goes the dog! [/code] For more details see also: [url]http://www.daniweb.com/forums/post761691-154.html[/url]

Member Avatar for sneekula
0
220
Member Avatar for Ene Uran

I never knew what real happiness was until I got married, and by then it was too late.

Member Avatar for vegaseat
0
160
Member Avatar for The Dude

[QUOTE=The Dude;772588]A virtual archive of wills and other documents from some of historys famous people. [url]http://dude111.fileave.com/famous.pdf[/url][/QUOTE] Very interesting stuff.

Member Avatar for The Dude
0
68
Member Avatar for revenge2

Very simple ... [code=python]list1 = ['1','2','3'] list2 = ['4','5','6'] list3 = ['7','8','9'] all = list1 + list2 + list3 print(all) # ['1', '2', '3', '4', '5', '6', '7', '8', '9'] del list1 del list2 del list3 [/code] Note: You should open a new thread for unrelated questions and give the …

Member Avatar for mn_kthompson
0
363
Member Avatar for revenge2

[QUOTE=evstevemd;768548]I use one tab or four spaces They give me no problem, so I guess: 1Tab = 4spaces[/QUOTE]I think Ene is right here, please don't use tabs for indentations, they are bound to mix with spaces! I actually noticed one of evstevemd's wxPython code samples that I copied and pasted …

Member Avatar for mn_kthompson
0
122
Member Avatar for GrimJack

[QUOTE=Ancient Dragon;722923]... Something, or someone, had to create the universe -- it didn't just happen out of nothing. Even if you believe the Big Bang theory, someone had to create that mass that exploded. ...[/QUOTE]In that line of thinking, who created the creator? Big Bang only relates to the universe …

Member Avatar for GrimJack
0
1K
Member Avatar for sillyboy
Member Avatar for lllllIllIlllI

I left a few notes on Python30 here: [url]http://www.daniweb.com/forums/showpost.php?p=761691&postcount=154[/url] Python30 will modernize the language. The I/O changes, like print() and input(), will effect us the most. Future posters will have to tell us which version of Python is used.

Member Avatar for Stefano Mtangoo
0
117
Member Avatar for AstralCorpse

Okay, this is what I tried ... [code=python]import random word = raw_input("Enter a word: ") wordsize = len(word) randomnumber = random.randrange(0, wordsize) c = word[randomnumber] print c, c.isdigit() """ one result after entering hello --> Enter a word: hello l False <--- this means that l is the letter l …

Member Avatar for mn_kthompson
0
135
Member Avatar for gsingh2011
Member Avatar for christina>you
Member Avatar for mayo_tech11

Kenneth C. Davis' "Don't Know Much About Mythology" strikes my fancy.

Member Avatar for techbound
0
2K
Member Avatar for MaracKoMarac
Member Avatar for MaracKoMarac
0
81
Member Avatar for leb
Member Avatar for Stefano Mtangoo

Here is an example ... [code=python]# using the module ctypes you can access DLLs written in C/C++ # ctypes converts between Python types and C types # there are two ways to write DLLs: # most common uses cdecl, import with cdll # Win and VB may use stdcall, import …

Member Avatar for Stefano Mtangoo
0
536
Member Avatar for tomtetlaw

Which editor are you using. My guess is that you are using PyScripter.

Member Avatar for tomtetlaw
0
166
Member Avatar for Ancient Dragon

Well, Microsoft could have come up with something less childish, but then they have pretty much a monopoly in the PC OS market. There was not really an incentive to do better.

Member Avatar for Jen0608
3
400
Member Avatar for Micko

A little twist here, the Python24.dll contains all the PyEval routines and they are most likely written in C. So I wonder, if you couldn't access them directly from the dll in your C/C++ program.

Member Avatar for hunkaboy2003
0
4K
Member Avatar for mmeclimate
Member Avatar for mmeclimate
0
2K
Member Avatar for Stefano Mtangoo

Strange, in onCheck() I did a few testprints ... print self.player.Load(path) --> True print self.player.Play() --> False, should be True print self.player.Length() --> 0, should be > 0 It seems to load the media file correctly. Actually, when you load an .avi file and press stop the first frame shows. …

Member Avatar for Stefano Mtangoo
0
171
Member Avatar for Lardmeister

To bad there are only 10 choices maximum to give a poll at DaniWeb. I guess string instruments have to put under guitar. I like the viola.

Member Avatar for ddanbe
0
478

The End.