2,190 Posted Topics

Member Avatar for MrKnowNothing

First, when you call isprime() on the last line, you have to pass a number to test to the function, and you have to receive the result. Then you want to print out the result. As far as error messages, while testing, put some print statements in the body of …

Member Avatar for woooee
0
74
Member Avatar for CoolFool

You can also use: [code]if score < 60: grade="F" elif score < 70: grade="D" elif score < 80: grade="C" elif score < 90: grade="B" elif score < 101: grade="A" else: print score, "is bogus"[/code]but as stated earlier, it depends on what makes sense to you. i.e. what the outline is. …

Member Avatar for woooee
0
166
Member Avatar for jliu66

Code something up and try it for yourself. If you get an error message then post the code here for some help.

Member Avatar for jliu66
0
13K
Member Avatar for arkad

Also, you might subprocess instead. From the Python docs: "The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes." [url]http://blog.doughellmann.com/2007/07/pymotw-subprocess.html[/url]

Member Avatar for arkad
0
1K
Member Avatar for Panarchy

Sourceforge seems to have a few possibilities like Forum Handler. You'll have to see what works for you. [URL]http://sourceforge.net/search/?words=python+forum&type_of_search=soft&pmode=0&inex=1&sortselect=trove__160&registration_date__0=&trove__225=456&trove__274=369&trove__160=178&trove__199=426&trove__13=14&trove__1=534&trove__6=7&trove__496=499&newfilter=Apply[/URL]

Member Avatar for Panarchy
0
122
Member Avatar for mathijs

Look through the projects for beginner thread. This or something similiar is sure to be there.

Member Avatar for mathijs
0
148
Member Avatar for jliu66

[quote=jliu66;455786]But you can see there is no function in last line of code at all: SizeDiffE(k) = j[/quote] Try a print type(SizeDiffE) to see what it is. Also, if SizeDiffE(k) is not passing 'k' to the function SizeDiffE() then what is it doing. If it is a tuple, then it …

Member Avatar for woooee
0
232
Member Avatar for jliu66

[QUOTE]How can I sort it by any columns?[/QUOTE]There is a way to do this using a function, but you will have to at least __try__ to do it yourself first and then post the code here. I hope you understand that it is considered rude to "place your code order" …

Member Avatar for Lardmeister
0
169
Member Avatar for jliu66

First off, Python doesn't really have arrays unless you include some of the add on packages. Python uses lists, so I would suggest that you take a look at lists. Combining is a simple matter. You can iterate through the lists with a for loop, creating a new list with …

Member Avatar for jliu66
0
743
Member Avatar for jobs

set.Set has nothing named elems. Beyond that it is hard to say. Post a question to the author at ActiveState, or e-mail them directly if there is an address. Also, post some code with what it is you are trying to do so someone can come up with something that …

Member Avatar for vegaseat
0
614
Member Avatar for tesak

Look at the line following elif status == 0.3: And why do you have if/elif? Why not just print the value?

Member Avatar for jrcagle
0
106
Member Avatar for axn

It would be better to use an existing tool like Metakit or SQLite. This pages show how it would be done with Metakit [url]http://www.equi4.com/metakit/python.html[/url]

Member Avatar for ghostdog74
0
119
Member Avatar for Raulito

[QUOTE=Ene Uran;439119]This is such an easy problem, I suggest you really try to understand it![/QUOTE] Also, a Google for "fibonacci python" has everything anyone could want. These posters are too lazy to ever make it as a programmer.

Member Avatar for woooee
0
112
Member Avatar for OLer94

Try append instead of add. Any tutorial or on-line book can help you with lists and how to add/append items.

Member Avatar for OLer94
0
143
Member Avatar for rjmiller

[quote=rjmiller;430827] 1 hydrogen H 1.0079 [code] if len(parts) == 4: print float.parts[4] else print 0 '%s does not have a well defined atomic weight.' % s(parts[3])[/code][/quote]The elements in a list are numbered from 0 to length, so your list is [0]-->[3]. Since you didn't ask any questions, I have to …

Member Avatar for rjmiller
0
190
Member Avatar for grahhh

[quote=grahhh;429382]This is a simplification of what the data looks like (hundreds of lines like this): [two spaces]6.0730000e+003[tab][one space]-9.2027000e+004[tab][two spaces]7.8891354e+01[tab]\r\n[/quote]string.split() treats all whites space (space, tab, newline) the same s=" 6.0730000e+003\t -9.2027000e+004\t 7.8891354e+01\t\r\n" print s.split() ['6.0730000e+003', '-9.2027000e+004', '7.8891354e+01']

Member Avatar for paddy3118
0
185
Member Avatar for StrikerX11

>>> a=b="test" >>> print a test >>> print b test >>> id(a) 3084724384L >>> id(b) 3084724384L Or convert the string to a list and then back to a string when you are finished.

Member Avatar for jrcagle
0
112
Member Avatar for ian14

[URL]http://www.python-eggs.org/[/URL] has links to other sites organized by type. For code examples google activestate.com and faqts.com

Member Avatar for woooee
0
93
Member Avatar for galbi

I was just thinking about this myself and came up with ClientForm, but haven't tried it yet. [url]http://wwwsearch.sourceforge.net/ClientForm/[/url]

Member Avatar for N317V
0
108
Member Avatar for shadwickman

It is easiest to write the data to a file, close it, and then call lpr using os.system() providing you want plain text. Anything more and you have to format it. Postscript is the easiest way to format output.

Member Avatar for shadwickman
0
185
Member Avatar for irotsenmar

See this quote on the main page " We only give homework help to those who show effort"

Member Avatar for jrcagle
0
113
Member Avatar for muddpigeon

If I enter any pin number, the program will accept it because it is > 1000 or < 9999[code]#Checks if pin is within range of 1000 to 9999 valid = 0 while not valid : if (pin > 999) and (pin < 10000) : print "Pin accepted" if pin== x: …

Member Avatar for muddpigeon
0
124
Member Avatar for pareshv22
Member Avatar for Ene Uran
0
87
Member Avatar for dav_yip
Member Avatar for defience

You might want to try [code] import string file_pointer= open('wordlist.txt', 'U') dictList = file_pointer.readlines() file_pointer.close() x = 0 newDict = '' stop = len(dictList) while x < stop: ## you could also use "for each_rec in dictList :" [/code]

Member Avatar for defience
0
127
Member Avatar for Jergosh

[quote=Jergosh;307508]each plugin .py file is executed (via execfile()) by the PluginManager[/quote] I am not 100% sure what you are doing, but wouldn't you want the PluginManager to be an inherited class. It should also have methods to keep track of all plugins created, which "self.Plugins[newplugin.name] = newplugin" should provide, if …

Member Avatar for woooee
0
98
Member Avatar for jrcagle

If you want to find file date, stats = os.stat( filename ) print time.ctime( stats[8] ) prints 'Tue Dec 26 14:28:16 2006' string.split, etc. yields the month, although I think you should also take the year into account.

Member Avatar for jrcagle
0
140
Member Avatar for incitatus

If you just want to download, you can use wget with the --user and --password options with a frontend to call it at specific times. I don't know if that will solve the problem, but it does have a resume option, so you at least won't have to start over …

Member Avatar for incitatus
0
116
Member Avatar for dams

This will print your PYTHONPATH. If the path you want is not listed, and it shouldn't be because your program isn't found, then you have to use sys.path.append to add it.[code] import sys path_list= sys.path for eachPath in path_list : print eachPath[/code]

Member Avatar for dams
0
127
Member Avatar for mattyd

I like your solution, and I don't think there is any other way to handle the ace problem[quote]but was informed by one of my students that I put in a poker-like betting system instead of the blackjack betting system[/quote]They always know more than we do. Viva la future.

Member Avatar for woooee
0
108
Member Avatar for goms

[quote=goms;302388] import win32API.client ImportError: No module named win32API.client[/quote]I use Linux, but I think you would want to import win32API, without '.client' although I'm not sure. If that fails, search for win32API on you system. It is likely that you have to append the path to PYTHONPATH using sys.path.append( some_path_name). EDIT: …

Member Avatar for vegaseat
0
220
Member Avatar for Matt Tacular

[quote]... one of the while loops has an eternally unfulfilled condition.[/quote] This is the only thing that could cause this problem (so of course it's something else). Add a separate counter to each while loop and exit after max cycles. [code]ctr_1 = 0 while True : ctr_1 += 1 if …

Member Avatar for woooee
0
96
Member Avatar for babutche

Instead of self.hours=credits. do you want to total them self hours += credits

Member Avatar for babutche
0
1K
Member Avatar for sneekula

[QUOTE=sneekula;299775]How does Python handle mixed type lists to get such a result?[/QUOTE] Pretty much, all pc's use ascii encoding and sort in "ascii order", see [url]http://www.asciitable.com/[/url]

Member Avatar for vegaseat
0
3K
Member Avatar for babutche

[code]def main(): grade_str = raw_input("Enter gradepoint or (Enter to quit): ") if grade_str == "": break try: grade = float(grade_str) except ValueError: print "Error, use floating point number" return[/code]You want the "try :" statement as the first statement after "while 1:". That will give you an error message if a …

Member Avatar for babutche
0
147
Member Avatar for babutche

[quote] File "C:\Python23\p2sort.py", line 40, in main if dfield == gpa: NameError: global name 'gpa' is not defined[/quote] I think you want "gpa" in quotes. if dfield == "gpa": A simple menu would be easier for the user, with 1=gpa, etc. In any case, you should have a list of …

Member Avatar for babutche
0
466
Member Avatar for Matt Tacular

[QUOTE]Another error that happens is if the program is expecting a number and gets a letter.[/QUOTE][CODE]if input_string.isdigit(): do_something() else : print "Enter a number"[/CODE][QUOTE]if someone hits enter by mistake without entering anything, it errors, is there a way to avoid that?[/QUOTE][CODE]if (input_string) and len(input_string) > 0 : ## -----or try …

Member Avatar for bumsfeld
0
186
Member Avatar for babutche

Not sure if this is what you want to do or not, but try replacing [CODE] else: value = fib(n-1)+fib(n-2) ## with else: value = fib(n-1)[/CODE]You might also want to use a list to store the two fib numbers, since fibs are not sequential. Again, not sure what you are …

Member Avatar for babutche
0
129
Member Avatar for babutche

[QUOTE] I cannot get my return of the Fibonacci number to work properly and when I ran this program with fib(10) it ran forever.[/QUOTE]'Ran forever' because you are calculating using the same number over and over. Look at your output. If you want to compute a fib you first have …

Member Avatar for woooee
0
109
Member Avatar for Matt Tacular

You can use type() [code] x = random.randint(0,10) y = random.randint(0,10) li = [1,2] li2 = [x,y] test_list = [] if every_value of li2 is in li: if type(every_value) == type(test_list) : do this [/code]Note that 'of li2 is in li' will compare entire list to list, not each element, …

Member Avatar for vegaseat
0
173

The End.