2,190 Posted Topics

Member Avatar for amini.chenini

What is "patrons"? It looks like a list of Patron class instances. If so, please include the Patron class code also. In loan_book() you only check the book_id if the patron is not found. If the patron is found you return before the book lookup.

Member Avatar for woooee
0
240
Member Avatar for Jade87

There is no reason to reinvent the wheel. You can use the identify program from ImageMagick to do that for you.

Member Avatar for Jade87
0
375
Member Avatar for dean.ong.14

You can [bind the <BackSpace> key](http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm) to a function just like any other key. If you want to erase the last character in and entry widget for example, then get the value and set it as value[:-1] For button examples, like a quit button see a tutorial [like this one](http://www.greenteapress.com/thinkpython/html/thinkpython020.html)

Member Avatar for TrustyTony
0
499
Member Avatar for lewashby

You can also use subprocess to get the results of ls -l. Note the r(epr) import subprocess output = subprocess.check_output([r'ls', '-l']) print output

Member Avatar for woooee
0
540
Member Avatar for 06njack

I would suggest a few print statements to see what the program is doing. Other than that, you did not say what you wanted the program to do and what the problem is (and I have learned that you are always wrong if you try to guess). Also, are you …

Member Avatar for woooee
0
284
Member Avatar for booicu

You have to pass the "numbers" list to do_analysis. Now it is using the "numbers" from the import numbers statement. This is not a complete solution but should get you started: [passing parameters to a function](http://www.tutorialspoint.com/python/python_functions.htm) def main (): # create empty list intro() numbers = get_values() ## get_values() Huh!! …

Member Avatar for woooee
0
17K
Member Avatar for CodingCabbage

Geometry managers, pack, grid, and place return None canvas = Canvas(mainGUI, width=c_width, height=c_height, bg= 'white').place(x=(4.5*(widthOfScreen/12)),y= (2*(heightOfScreen/5))) print canvas Take a look at Vegas's code again and I'm sure you will find that the geometry manager is on a separate line. canvas = Canvas(mainGUI, width=c_width, height=c_height, bg= 'white') print canvas print …

Member Avatar for CodingCabbage
0
3K
Member Avatar for CodingCabbage

Generally you add each "button_name" instance to a list that remains after the loop exits. Note that you also want to increment/change the values for the place manager.

Member Avatar for vegaseat
0
243
Member Avatar for lewashby

Take a look at the docs for os.stat() def file_permissions( fname ) : st = os.stat(fname) ##--- st = tuple, in format ## 0 1 2 3 4 5 6 7 8 9 ## (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime) mode = st[0] if mode : print "st_mode = ", mode if mode & stat.S_ISLNK(st[stat.ST_MODE]) …

Member Avatar for lewashby
0
149
Member Avatar for Waseemaburakia

Note that you don't use the "j" variable. It is not necessary. Just iterate through the the list up to the next to last element. You do this over and over until there are no more swaps. In your code you loop enough times to do all of the swaps …

Member Avatar for Waseemaburakia
0
294
Member Avatar for sinnebril
Member Avatar for Stefano Mtangoo

SQLite is also packaged with Python 3.x. PostgreSQL has pg8000-py3. Don't know about MySQL or any of the others.

Member Avatar for vegaseat
0
985
Member Avatar for Pioggia254

You want to increment count after every input. You do not increment it after the first input statement. Also the final else is not necessary. import random count = 0 secret = random.randint (1, 100) print ("Guessing game - Guess my secret number - number between 1-100") guess = int(input("Your …

Member Avatar for vegaseat
0
173
Member Avatar for flebber

Your code is a good example of why we use the [Python Style Guide](http://www.python.org/dev/peps/pep-0008/) You use an upper and lower case "L" for the same field name so the code you posted does not run. The style guide says to use lower_case_with_underscores so to avoid that problem and make your …

Member Avatar for flebber
0
542
Member Avatar for Remy the cook

You may also have problems with capitalized vs all lower case words. Since I have no idea what "nltk.pos_tag(token_text)" is and don't have the time to search for it, the following code will count the number of words but will have a problem with punctuation you want to keep, like …

Member Avatar for Remy the cook
0
1K
Member Avatar for Ismatus3

> modelsa,date,heure,%s You can't have a named field as "%s" It has to be the field name so you will have to use if statements or create the 'insert into' as a string containing the field names themselves. if e0 = =1: cur.execute('insert into suiviactuelms (modelsa,date,heure,field1) values (%s,%s,%s,%s);',(modelidvar, cur_date, t, …

Member Avatar for woooee
0
582
Member Avatar for glao

Use "if len(a_list)". Also this is what [sets](http://en.wikibooks.org/wiki/Python_Programming/Sets) are for if set(a_list).issubset(set(a_string)) ## if all list is in string

Member Avatar for glao
0
505
Member Avatar for glao

You have not done anything to find out what is going on so that is why you don't know. Two added print statements will show what pyTony said, i.e. you don't accumulate the count but just return each individual count from each recursion. def lengthR(mystring): ''' recursive function to count …

Member Avatar for glao
0
193
Member Avatar for glao

> but it returns : _iNone The "None" is returned by the function so apparently you are calling it with "print function_name()" instead of "function_name". If that does not help then post the entire code including how you call it.

Member Avatar for glao
0
149
Member Avatar for Rebecca_2

> I am trying to write a program which, overall takes the names of the files that haven't completed, works out the names of those that haven't run and writes all of these into a batch file. I would agree. You are perhaps making it too complicated. Write/store the file …

Member Avatar for woooee
0
391
Member Avatar for bnn678

I get errors on lines 3, 11, and 14 so I can't get any output to test for a float.

Member Avatar for bnn678
0
374
Member Avatar for stevewilliams02

Google is the best way to find an answer as without code there is no way to tell what "GUI" you wish to use. One example from this forum [Click Here](http://www.daniweb.com/software-development/python/code/216581/wxpython-gui-to-display-a-jpeg-.jpg-image)

Member Avatar for HiHe
0
328
Member Avatar for rabowling

There is a logic error in the code, if someone answers "no" as q_two they still get the q_three = raw_input("Do you pick the revolver up?") statement. Also, you want to limit the input to specific answers. q_two = "" while q_two.lower() not in ("no", "yes"): q_two = raw_input("Do you …

Member Avatar for vegaseat
0
496
Member Avatar for glez_b

You first have to be able to access each individual row and know what format the row is in; string, list, etc. We do not know this so any code would be shooting in the dark.

Member Avatar for vegaseat
0
9K
Member Avatar for Vusumuzi

The else statement in the following code executes if the number is equal to or greater than since you don't test for an equal condition and will print "try a lower number" when equal. You should test for greater than only as the while loop catches the equal condition. Your …

Member Avatar for fonzali
0
244
Member Avatar for ant1vanden

Convert to a list of lists with highest score first, then time, then name. Or take a look at "Complex Sorts" in the [Howto Sorting](https://wiki.python.org/moin/HowTo/Sorting)

Member Avatar for vegaseat
0
171
Member Avatar for Alexander_2

An example of placing a gif image on a canvas [Click Here](http://www.daniweb.com/software-development/python/code/216550/tkinter-to-put-a-gif-image-on-a-canvas-python) Most people who are attempting a hangman game use a canvas and [draw lines, circles] (http://effbot.org/tkinterbook/canvas.htm) etc. to get the hangman, but it is your program. You might also consider a [Toplevel](http://effbot.org/tkinterbook/toplevel.htm) i.e. a second window for the …

Member Avatar for vegaseat
0
8K
Member Avatar for marethamogale

It sounds like we are being given an assignment to "write a program" etc. for someone else. Not a good way to get assistance.

Member Avatar for vegaseat
-1
134
Member Avatar for krystosan

For the record, the way to achieve the results that I think the OP is looking for is to use from sys import path I prefer to import sys and use sys.path because it makes the namespaces obvious.

Member Avatar for woooee
0
188
Member Avatar for glez_b

> and Moisture for the 31 day of the month, > > and Moisture for the 31 day of the month Split the rec to isolate the date and split the date into month, day, and year. rec="1/01/2011, 00:00, 23, 50, 2," split_on_space = rec.split() print split_on_space[0] mm, dd, ccyy …

Member Avatar for glez_b
0
3K
Member Avatar for 123pythonme

10 to the 5=100,000 and you only have to test up to the square root and every other number, i.e. not even, which is slightly more than 150 numbers if my arithmetic is correct. So it has to be some other problem. Check any while() loops and that you are …

Member Avatar for vegaseat
0
262
Member Avatar for sophia_sin

There is a little hiccup for stars with 3 and 4 sides. You can divide 360 by the number of sides for stars with 5 sides and up, but for 3 or 4 sides this gives an angle greater than or equal to 90 which will not work. I will …

Member Avatar for woooee
0
176
Member Avatar for 123pythonme

I would strongly suggest that you print "p" to see what it contains and then look at what you are sending to the function for p in primes: if n % p == 0: return False

Member Avatar for vegaseat
0
581
Member Avatar for Spider_14

set a [StringVar or IntVar](http://effbot.org/tkinterbook/variable.htm) in the command callback, "get" example [here](http://effbot.org/tkinterbook/entry.htm) but set works the same way. Start at "This example creates an Entry widget, and a Button that prints the current contents:"

Member Avatar for woooee
0
127
Member Avatar for hmx7

999 can't stop your program because of elif grade > 101: Try using (but it still errors if a non-number/letter is entered) grade = -1 while grade != 999: grade = int(input('Enter a grade that is greater than zero: ')) if 0 <= grade < 101: ## do calcs for …

Member Avatar for hmx7
0
152
Member Avatar for hmx7

You zero the totals before the loop instead of under it for i in range(stop1) : totalgp = 0 totalgp1 = 0 stop = int(input('Enter the number of classes you have: ')) and you can now delete stop -= 1 stop1 -= 1 since the for() loop uses a different …

Member Avatar for hmx7
0
185
Member Avatar for antonio.neal.39

A simple example class Massage_DontCallMeMessage(): def __init__(self): gui = Tk() gui.geometry('1500x100+10+600') gui.title('ALARTS') gui.config (bg = 'blue') self.massage = Label(gui, text = 'this is a demo') self.massage.config (fg = 'white',bg = 'blue', font=('times','60')) self.massage.place( x = 1,y = 0,) self.ctr = 0 self.change_it() gui.mainloop() def change_it(self): orig_text='this is a demo ' …

Member Avatar for antonio.neal.39
0
296
Member Avatar for phorce

This works per your example. However you don't have a queue.put() so you won't get anything from the get() call. I don't think that is what you want however. Look up [shared data](http://docs.python.org/2/library/multiprocessing.html#sharing-state-between-processes) perhaps a dictionary or list would be easiest to understand depending on the size of the data. …

Member Avatar for woooee
0
271
Member Avatar for RHNation

You can not have any character, including a space, after the line continuation character "\" print('Based on a weight of', format(package_weight, '.2f'),\ 'pounds, the shipping charge is $', format(cost, '.2f'),sep=' ')

Member Avatar for Lardmeister
0
4K
Member Avatar for bright.silva

I am not an expert, and this is more code than I want to wade through, so am not positive about what you are trying to do. The first part, to get the difference between numbers that occur in more than one set, is below. The program breaks the test …

Member Avatar for bright.silva
0
153
Member Avatar for Paraborn

A simpler way to add up the first two numbers. def addFirstNums(num_in): multBy2 = num_in*2 y = 0 ## convert to string and cut to two digits if more than two ## doesn't matter if one or more digits newDig = str(multBy2)[:2] for num in newDig: y += int(num) print …

Member Avatar for woooee
0
243
Member Avatar for Rebecca_2

You can send a tuple to startswith ## note that opt is never set back to "" or "n" if s.startwith(('Total number of defects', 'Total charge on defect', etc.)) Are you saying that you want to stop looking after the second if s=='**** Optimisation achieved ****': if s=='**** Optimisation achieved …

Member Avatar for snippsat
0
286
Member Avatar for Meikell 'Kai'

That is more code than I want to trudge through for a simple question, so will just say that generally you use [Toplevels](http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/toplevel.html) as the code below illustrates. If there is more that you wish to know, post back. Note that you can use a function or third class to …

Member Avatar for Meikell 'Kai'
0
2K
Member Avatar for ggsr45

Once you get to the string you want to use you can split it new_str = '{reason:slash,data:{"""REM_1""": """=0xFF""", """REM_2""": """=0x1""", """SET0:REM_3""": """=SET2:REM_3""", """MREM_4""": """=0xFF"""};{}}' x= new_str.split('"""') print x[13], x[15] print x[5], x[7]

Member Avatar for ggsr45
0
180
Member Avatar for RHNation

Try: float(outputt) == float(abs(int(outputt))) except ValueError: print("Not a valid number. Please enter a valid number.") else: return float(outputt) "try" is not capitalized This statement does not make sense, float(outputt) == float(abs(int(outputt))) and there is no reason to convert to an int and then convert to a float since converting to …

Member Avatar for farmwife
0
302
Member Avatar for HiHe

Print sys.maxint to see what it says. You are probably going beyond the computer's limit. It depends on your OS: 32 bit or 64 bit. For more precision take a look at the decimal module. If you want to actually do anything with a number than contains 180,000 digits, decimal …

Member Avatar for vegaseat
0
338
Member Avatar for Hikki_Passion

For the example line you gave [code]def find_attribute_value(html_tag, att): ## is att in html? if att in html_tag: ## find the location of att idx = html_tag.find(att) ##split on the quotation marks for everything after att first_split = html_tag[idx:].split('"') print first_split[1] else: print "attribute %s Not Found" % (att) def …

Member Avatar for james.lu.75491856
0
1K
Member Avatar for hisan

[QUOTE=;][/QUOTE] Generally, you would store the next time you want to execute, i.e. now+10 seconds, using a loop, call the function, upon the return get the time and calculate the difference between it and the next time and sleep that amount of time, update the next time, (+10 seconds), and …

Member Avatar for 3e0jUn
0
1K
Member Avatar for wolf29

> The first iteration of the for loop runs, but nothing else. That is because of the "if counter > 0" for counter,row in enumerate(reader): if counter > 8: continue You also have an extra semicolon at the end of this statement Cur.execute("INSERT INTO vulnerabilities(IP) VALUES ('vuln_0');") I will try …

Member Avatar for wolf29
0
326
Member Avatar for jpk1a873

Vegaseat started a number to words thread http://www.daniweb.com/software-development/python/code/216839/number-to-word-converter-python

Member Avatar for woooee
0
8K

The End.