Index: tkinter/guido/solitaire.py =================================================================== --- tkinter/guido/solitaire.py (revision 61156) +++ tkinter/guido/solitaire.py (working copy) @@ -168,7 +168,7 @@ self.group = Group(canvas) text = "%s %s" % (VALNAMES[value], suit) - self.__text = CanvasText(canvas, CARDWIDTH/2, 0, + self.__text = CanvasText(canvas, CARDWIDTH//2, 0, anchor=N, fill=self.color, text=text) self.group.addtag_withtag(self.__text) @@ -589,7 +589,7 @@ def animatedmoveto(self, card, dest): for i in range(10, 0, -1): - dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i + dx, dy = (dest.x-card.x)//i, (dest.y-card.y)//i card.moveby(dx, dy) self.master.update_idletasks() Index: tkinter/guido/sortvisu.py =================================================================== --- tkinter/guido/sortvisu.py (revision 61156) +++ tkinter/guido/sortvisu.py (working copy) @@ -88,7 +88,7 @@ if self.speed == "fastest": msecs = 0 elif self.speed == "fast": - msecs = msecs/10 + msecs = msecs//10 elif self.speed == "single-step": msecs = 1000000000 if not self.stop_mainloop: @@ -320,7 +320,7 @@ return outcome def position(self): - x1 = (self.index+1)*XGRID - WIDTH/2 + x1 = (self.index+1)*XGRID - WIDTH//2 x2 = x1+WIDTH y2 = (self.array.maxvalue+1)*YGRID y1 = y2 - (self.value)*YGRID @@ -349,7 +349,7 @@ res = [tuple(oldpts)] for i in range(1, n): for k in range(len(pts)): - pts[k] = oldpts[k] + (newpts[k] - oldpts[k])*i/n + pts[k] = oldpts[k] + (newpts[k] - oldpts[k])*i//n res.append(tuple(pts)) res.append(tuple(newpts)) return res @@ -359,7 +359,7 @@ def uniform(array): size = array.getsize() - array.setdata([(size+1)/2] * size) + array.setdata([(size+1)//2] * size) array.reset("Uniform data, size %d" % size) def distinct(array): @@ -429,7 +429,7 @@ j = j-1 continue array.message("Choosing pivot") - j, i, k = first, (first+last)/2, last-1 + j, i, k = first, (first+last)//2, last-1 if array.compare(k, i) < 0: array.swap(k, i) if array.compare(k, j) < 0: Index: tkinter/guido/hanoi.py =================================================================== --- tkinter/guido/hanoi.py (revision 61156) +++ tkinter/guido/hanoi.py (working copy) @@ -35,15 +35,15 @@ # Add background bitmap if bitmap: - self.bitmap = c.create_bitmap(width/2, height/2, + self.bitmap = c.create_bitmap(width//2, height//2, bitmap=bitmap, foreground='blue') # Generate pegs pegwidth = 10 - pegheight = height/2 - pegdist = width/3 - x1, y1 = (pegdist-pegwidth)/2, height*1/3 + pegheight = height//2 + pegdist = width//3 + x1, y1 = (pegdist-pegwidth)//2, height*1//3 x2, y2 = x1+pegwidth, y1+pegheight self.pegs = [] p = c.create_rectangle(x1, y1, x2, y2, fill='black') @@ -57,14 +57,14 @@ self.tk.update() # Generate pieces - pieceheight = pegheight/16 - maxpiecewidth = pegdist*2/3 + pieceheight = pegheight//16 + maxpiecewidth = pegdist*2//3 minpiecewidth = 2*pegwidth self.pegstate = [[], [], []] self.pieces = {} - x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 + x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2 x2, y2 = x1+maxpiecewidth, y1+pieceheight - dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) + dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1)) for i in range(n, 0, -1): p = c.create_rectangle(x1, y1, x2, y2, fill='red') self.pieces[i] = p @@ -101,10 +101,10 @@ # Move it towards peg b bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) - newcenter = (bx1+bx2)/2 + newcenter = (bx1+bx2)//2 while 1: x1, y1, x2, y2 = c.bbox(p) - center = (x1+x2)/2 + center = (x1+x2)//2 if center == newcenter: break if center > newcenter: c.move(p, -1, 0) else: c.move(p, 1, 0) Index: pdist/cmptree.py =================================================================== --- pdist/cmptree.py (revision 61156) +++ pdist/cmptree.py (working copy) @@ -197,7 +197,7 @@ dt = t2-t1 print size, "bytes in", round(dt), "seconds", if dt: - print "i.e.", int(size/dt), "bytes/sec", + print "i.e.", size//dt, "bytes/sec", print remote._recv(id) # ignored Index: rpc/xdr.py =================================================================== --- rpc/xdr.py (revision 61156) +++ rpc/xdr.py (working copy) @@ -57,7 +57,7 @@ def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' - n = ((n+3)/4)*4 + n = ((n + 3)//4)*4 data = s[:n] data = data + (n - len(data)) * '\0' self.buf = self.buf + data @@ -164,7 +164,7 @@ if n < 0: raise ValueError, 'fstring size must be nonnegative' i = self.pos - j = i + (n+3)/4*4 + j = i + (n+3)//4*4 if j > len(self.buf): raise EOFError self.pos = j Index: md5test/md5driver.py =================================================================== --- md5test/md5driver.py (revision 61156) +++ md5test/md5driver.py (working copy) @@ -32,7 +32,7 @@ filsiz = 1 << 8 filler = makestr(0, filsiz-1) - data = filler * (TEST_BLOCK_SIZE / filsiz); + data = filler * (TEST_BLOCK_SIZE // filsiz); data = data + filler[:(TEST_BLOCK_SIZE % filsiz)] del filsiz, filler Index: scripts/markov.py =================================================================== --- scripts/markov.py (revision 61156) +++ scripts/markov.py (working copy) @@ -110,7 +110,7 @@ def tuple(list): if len(list) == 0: return () if len(list) == 1: return (list[0],) - i = len(list)/2 + i = len(list)//2 return tuple(list[:i]) + tuple(list[i:]) if __name__ == "__main__": Index: scripts/lpwatch.py =================================================================== --- scripts/lpwatch.py (revision 61156) +++ scripts/lpwatch.py (working copy) @@ -83,7 +83,7 @@ lines.append(line) # if totaljobs: - line = '%d K' % ((totalbytes+1023)/1024) + line = '%d K' % ((totalbytes+1023)//1024) if totaljobs <> len(users): line = line + ' (%d jobs)' % totaljobs if len(users) == 1: @@ -95,7 +95,7 @@ line = line + ' (%s first)' % thisuser else: line = line + ' (%d K before %s)' % ( - (aheadbytes+1023)/1024, thisuser) + (aheadbytes+1023)//1024, thisuser) lines.append(line) # sts = pipe.close() Index: scripts/pi.py =================================================================== --- scripts/pi.py (revision 61156) +++ scripts/pi.py (working copy) @@ -17,11 +17,11 @@ p, q, k = k*k, 2L*k+1L, k+1L a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 # Print common digits - d, d1 = a/b, a1/b1 + d, d1 = a//b, a1//b1 while d == d1: output(d) a, a1 = 10L*(a%b), 10L*(a1%b1) - d, d1 = a/b, a1/b1 + d, d1 = a//b, a1//b1 def output(d): # Use write() to avoid spaces between the digits Index: scripts/ftpstats.py =================================================================== --- scripts/ftpstats.py (revision 61156) +++ scripts/ftpstats.py (working copy) @@ -104,7 +104,7 @@ def showbar(dict, title): n = len(title) - print '='*((70-n)/2), title, '='*((71-n)/2) + print '='*((70-n)//2), title, '='*((71-n)//2) list = [] keys = dict.keys() keys.sort() @@ -126,7 +126,7 @@ if len(dict) > maxitems: title = title + ' (first %d)'%maxitems n = len(title) - print '='*((70-n)/2), title, '='*((71-n)/2) + print '='*((70-n)//2), title, '='*((71-n)//2) list = [] keys = dict.keys() for key in keys: Index: scripts/unbirthday.py =================================================================== --- scripts/unbirthday.py (revision 61156) +++ scripts/unbirthday.py (working copy) @@ -92,9 +92,9 @@ # even though that day never actually existed and the calendar # was different then... days = year*365 # years, roughly - days = days + (year+3)/4 # plus leap years, roughly - days = days - (year+99)/100 # minus non-leap years every century - days = days + (year+399)/400 # plus leap years every 4 centirues + days = days + (year+3)//4 # plus leap years, roughly + days = days - (year+99)//100 # minus non-leap years every century + days = days + (year+399)//400 # plus leap years every 4 centirues for i in range(1, month): if i == 2 and calendar.isleap(year): days = days + 29 Index: scripts/fact.py =================================================================== --- scripts/fact.py (revision 61156) +++ scripts/fact.py (working copy) @@ -17,14 +17,14 @@ # Treat even factors special, so we can use i = i+2 later while n%2 == 0: res.append(2) - n = n/2 + n = n//2 # Try odd numbers up to sqrt(n) limit = sqrt(float(n+1)) i = 3 while i <= limit: if n%i == 0: res.append(i) - n = n/i + n = n//i limit = sqrt(n+1) else: i = i+2 Index: threads/Generator.py =================================================================== --- threads/Generator.py (revision 61156) +++ threads/Generator.py (working copy) @@ -64,11 +64,11 @@ p, q, k = k*k, 2L*k+1L, k+1L a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 # Print common digits - d, d1 = a/b, a1/b1 + d, d1 = a//b, a1//b1 while d == d1: g.put(int(d)) a, a1 = 10L*(a%b), 10L*(a1%b1) - d, d1 = a/b, a1/b1 + d, d1 = a//b, a1//b1 def test(): g = Generator(pi, ()) Index: classes/Dates.py =================================================================== --- classes/Dates.py (revision 61156) +++ classes/Dates.py (working copy) @@ -68,7 +68,7 @@ return 365 + _is_leap(year) def _days_before_year(year): # number of days before year - return year*365L + (year+3)/4 - (year+99)/100 + (year+399)/400 + return year*365L + (year+3)//4 - (year+99)//100 + (year+399)//400 def _days_in_month(month, year): # number of days in month of year if month == 2 and _is_leap(year): return 29 @@ -92,9 +92,9 @@ del ans.ord, ans.month, ans.day, ans.year # un-initialize it ans.ord = n - n400 = (n-1)/_DI400Y # # of 400-year blocks preceding + n400 = (n-1)//_DI400Y # # of 400-year blocks preceding year, n = 400 * n400, n - _DI400Y * n400 - more = n / 365 + more = n // 365 dby = _days_before_year(more) if dby >= n: more = more - 1 @@ -104,7 +104,7 @@ try: year = int(year) # chop to int, if it fits except (ValueError, OverflowError): pass - month = min(n/29 + 1, 12) + month = min(n//29 + 1, 12) dbm = _days_before_month(month, year) if dbm >= n: month = month - 1 Index: curses/life.py =================================================================== --- curses/life.py (revision 61156) +++ curses/life.py (working copy) @@ -158,7 +158,7 @@ board.display(update_board=False) # xpos, ypos are the cursor's position - xpos, ypos = board.X/2, board.Y/2 + xpos, ypos = board.X//2, board.Y//2 # Main loop: while (1): Index: curses/ncurses.py =================================================================== --- curses/ncurses.py (revision 61156) +++ curses/ncurses.py (working copy) @@ -77,38 +77,38 @@ stdscr.addstr("%d" % ((y + x) % 10)) for y in range(0, 1): p1 = mkpanel(curses.COLOR_RED, - curses.LINES / 2 - 2, - curses.COLS / 8 + 1, + curses.LINES // 2 - 2, + curses.COLS // 8 + 1, 0, 0) p1.set_userptr("p1") p2 = mkpanel(curses.COLOR_GREEN, - curses.LINES / 2 + 1, - curses.COLS / 7, - curses.LINES / 4, - curses.COLS / 10) + curses.LINES // 2 + 1, + curses.COLS // 7, + curses.LINES // 4, + curses.COLS // 10) p2.set_userptr("p2") p3 = mkpanel(curses.COLOR_YELLOW, - curses.LINES / 4, - curses.COLS / 10, - curses.LINES / 2, - curses.COLS / 9) + curses.LINES // 4, + curses.COLS // 10, + curses.LINES // 2, + curses.COLS // 9) p3.set_userptr("p3") p4 = mkpanel(curses.COLOR_BLUE, - curses.LINES / 2 - 2, - curses.COLS / 8, - curses.LINES / 2 - 2, - curses.COLS / 3) + curses.LINES // 2 - 2, + curses.COLS // 8, + curses.LINES // 2 - 2, + curses.COLS // 3) p4.set_userptr("p4") p5 = mkpanel(curses.COLOR_MAGENTA, - curses.LINES / 2 - 2, - curses.COLS / 8, - curses.LINES / 2, - curses.COLS / 2 - 2) + curses.LINES // 2 - 2, + curses.COLS // 8, + curses.LINES // 2, + curses.COLS // 2 - 2) p5.set_userptr("p5") fill_panel(p1) @@ -143,7 +143,7 @@ wait_a_while() saywhat("m2; press any key to continue") - p2.move(curses.LINES / 3 + 1, curses.COLS / 8) + p2.move(curses.LINES // 3 + 1, curses.COLS // 8) pflush() wait_a_while() @@ -153,7 +153,7 @@ wait_a_while() saywhat("m3; press any key to continue") - p3.move(curses.LINES / 4 + 1, curses.COLS / 15) + p3.move(curses.LINES // 4 + 1, curses.COLS // 15) pflush() wait_a_while() @@ -202,25 +202,25 @@ w5 = p5.window() saywhat("m4; press any key to continue") - w4.move(curses.LINES / 8, 1) + w4.move(curses.LINES // 8, 1) w4.addstr(mod[itmp]) - p4.move(curses.LINES / 6, itmp * curses.COLS / 8) - w5.move(curses.LINES / 6, 1) + p4.move(curses.LINES // 6, itmp * curses.COLS // 8) + w5.move(curses.LINES // 6, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m5; press any key to continue") - w4.move(curses.LINES / 6, 1) + w4.move(curses.LINES // 6, 1) w4.addstr(mod[itmp]) - p5.move(curses.LINES / 3 - 1, itmp * 10 + 6) - w5.move(curses.LINES / 8, 1) + p5.move(curses.LINES // 3 - 1, itmp * 10 + 6) + w5.move(curses.LINES // 8, 1) w5.addstr(mod[itmp]) pflush() wait_a_while() saywhat("m4; press any key to continue") - p4.move(curses.LINES / 6, (itmp + 1) * curses.COLS / 8) + p4.move(curses.LINES // 6, (itmp + 1) * curses.COLS // 8) pflush() wait_a_while() Index: sockets/ftp.py =================================================================== --- sockets/ftp.py (revision 61156) +++ sockets/ftp.py (working copy) @@ -91,7 +91,7 @@ hostname = gethostname() hostaddr = gethostbyname(hostname) hbytes = string.splitfields(hostaddr, '.') - pbytes = [repr(port/256), repr(port%256)] + pbytes = [repr(port//256), repr(port%256)] bytes = hbytes + pbytes cmd = 'PORT ' + string.joinfields(bytes, ',') s.send(cmd + '\r\n')