2,190 Posted Topics
Re: 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. | |
Re: There is no reason to reinvent the wheel. You can use the identify program from ImageMagick to do that for you. | |
Re: 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) | |
Re: 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 | |
Re: 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 … | |
Re: 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!! … | |
Re: 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 … | |
Re: 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. | |
Re: 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]) … | |
Re: 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 … | |
Re: Is this question solved or was clicking the solved button a mistake? | |
Re: SQLite is also packaged with Python 3.x. PostgreSQL has pg8000-py3. Don't know about MySQL or any of the others. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: > 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, … | |
Re: 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 | |
Re: 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 … | |
Re: > 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. | |
![]() | Re: > 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 … |
Re: I get errors on lines 3, 11, and 14 so I can't get any output to test for a float. | |
Re: 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) | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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) | |
Re: 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 … | |
Re: It sounds like we are being given an assignment to "write a program" etc. for someone else. Not a good way to get assistance. | |
Re: 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. | |
Re: > 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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:" | |
Re: 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 … | |
Re: 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 … | |
Re: 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 ' … | |
Re: 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. … | |
Re: 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=' ') | |
Re: 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 … | |
Re: 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 … | |
![]() | Re: 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 … |
Re: 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 … | |
Re: 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] | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: > 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 … | |
Re: Vegaseat started a number to words thread http://www.daniweb.com/software-development/python/code/216839/number-to-word-converter-python |
The End.