| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b877c4c commit fe126e3
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,7 +197,7 @@ def recvfile_real(local, remote, name): | |||
| 197 | 197 | dt = t2-t1 | |
| 198 | 198 | print size, "bytes in", round(dt), "seconds", | |
| 199 | 199 | if dt: | |
| 200 | - print "i.e.", int(size/dt), "bytes/sec", | ||
| 200 | + print "i.e.", size//dt, "bytes/sec", | ||
| 201 | 201 | print | |
| 202 | 202 | remote._recv(id) # ignored | |
| 203 | 203 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,7 +57,7 @@ def pack_double(self, x): | |||
| 57 | 57 | def pack_fstring(self, n, s): | |
| 58 | 58 | if n < 0: | |
| 59 | 59 | raise ValueError, 'fstring size must be nonnegative' | |
| 60 | - n = ((n+3)/4)*4 | ||
| 60 | + n = ((n + 3)//4)*4 | ||
| 61 | 61 | data = s[:n] | |
| 62 | 62 | data = data + (n - len(data)) * '\0' | |
| 63 | 63 | self.buf = self.buf + data | |
@@ -164,7 +164,7 @@ def unpack_fstring(self, n): | |||
| 164 | 164 | if n < 0: | |
| 165 | 165 | raise ValueError, 'fstring size must be nonnegative' | |
| 166 | 166 | i = self.pos | |
| 167 | - j = i + (n+3)/4*4 | ||
| 167 | + j = i + (n+3)//4*4 | ||
| 168 | 168 | if j > len(self.buf): | |
| 169 | 169 | raise EOFError | |
| 170 | 170 | self.pos = j | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,14 +17,14 @@ def fact(n): | |||
| 17 | 17 | # Treat even factors special, so we can use i = i+2 later | |
| 18 | 18 | while n%2 == 0: | |
| 19 | 19 | res.append(2) | |
| 20 | - n = n/2 | ||
| 20 | + n = n//2 | ||
| 21 | 21 | # Try odd numbers up to sqrt(n) | |
| 22 | 22 | limit = sqrt(float(n+1)) | |
| 23 | 23 | i = 3 | |
| 24 | 24 | while i <= limit: | |
| 25 | 25 | if n%i == 0: | |
| 26 | 26 | res.append(i) | |
| 27 | - n = n/i | ||
| 27 | + n = n//i | ||
| 28 | 28 | limit = sqrt(n+1) | |
| 29 | 29 | else: | |
| 30 | 30 | i = i+2 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,7 @@ def main(): | |||
| 104 | 104 | ||
| 105 | 105 | def showbar(dict, title): | |
| 106 | 106 | n = len(title) | |
| 107 | - print '='*((70-n)/2), title, '='*((71-n)/2) | ||
| 107 | + print '='*((70-n)//2), title, '='*((71-n)//2) | ||
| 108 | 108 | list = [] | |
| 109 | 109 | keys = dict.keys() | |
| 110 | 110 | keys.sort() | |
@@ -126,7 +126,7 @@ def show(dict, title, maxitems): | |||
| 126 | 126 | if len(dict) > maxitems: | |
| 127 | 127 | title = title + ' (first %d)'%maxitems | |
| 128 | 128 | n = len(title) | |
| 129 | - print '='*((70-n)/2), title, '='*((71-n)/2) | ||
| 129 | + print '='*((70-n)//2), title, '='*((71-n)//2) | ||
| 130 | 130 | list = [] | |
| 131 | 131 | keys = dict.keys() | |
| 132 | 132 | for key in keys: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,7 @@ def makestatus(name, thisuser): | |||
| 83 | 83 | lines.append(line) | |
| 84 | 84 | # | |
| 85 | 85 | if totaljobs: | |
| 86 | - line = '%d K' % ((totalbytes+1023)/1024) | ||
| 86 | + line = '%d K' % ((totalbytes+1023)//1024) | ||
| 87 | 87 | if totaljobs <> len(users): | |
| 88 | 88 | line = line + ' (%d jobs)' % totaljobs | |
| 89 | 89 | if len(users) == 1: | |
@@ -95,7 +95,7 @@ def makestatus(name, thisuser): | |||
| 95 | 95 | line = line + ' (%s first)' % thisuser | |
| 96 | 96 | else: | |
| 97 | 97 | line = line + ' (%d K before %s)' % ( | |
| 98 | - (aheadbytes+1023)/1024, thisuser) | ||
| 98 | + (aheadbytes+1023)//1024, thisuser) | ||
| 99 | 99 | lines.append(line) | |
| 100 | 100 | # | |
| 101 | 101 | sts = pipe.close() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,7 +110,7 @@ def test(): | |||
| 110 | 110 | def tuple(list): | |
| 111 | 111 | if len(list) == 0: return () | |
| 112 | 112 | if len(list) == 1: return (list[0],) | |
| 113 | - i = len(list)/2 | ||
| 113 | + i = len(list)//2 | ||
| 114 | 114 | return tuple(list[:i]) + tuple(list[i:]) | |
| 115 | 115 | ||
| 116 | 116 | if __name__ == "__main__": | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,11 +17,11 @@ def main(): | |||
| 17 | 17 | p, q, k = k*k, 2L*k+1L, k+1L | |
| 18 | 18 | a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 | |
| 19 | 19 | # Print common digits | |
| 20 | - d, d1 = a/b, a1/b1 | ||
| 20 | + d, d1 = a//b, a1//b1 | ||
| 21 | 21 | while d == d1: | |
| 22 | 22 | output(d) | |
| 23 | 23 | a, a1 = 10L*(a%b), 10L*(a1%b1) | |
| 24 | - d, d1 = a/b, a1/b1 | ||
| 24 | + d, d1 = a//b, a1//b1 | ||
| 25 | 25 | ||
| 26 | 26 | def output(d): | |
| 27 | 27 | # Use write() to avoid spaces between the digits | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,9 +92,9 @@ def mkdate((year, month, day)): | |||
| 92 | 92 | # even though that day never actually existed and the calendar | |
| 93 | 93 | # was different then... | |
| 94 | 94 | days = year*365 # years, roughly | |
| 95 | - days = days + (year+3)/4 # plus leap years, roughly | ||
| 96 | - days = days - (year+99)/100 # minus non-leap years every century | ||
| 97 | - days = days + (year+399)/400 # plus leap years every 4 centirues | ||
| 95 | + days = days + (year+3)//4 # plus leap years, roughly | ||
| 96 | + days = days - (year+99)//100 # minus non-leap years every century | ||
| 97 | + days = days + (year+399)//400 # plus leap years every 4 centirues | ||
| 98 | 98 | for i in range(1, month): | |
| 99 | 99 | if i == 2 and calendar.isleap(year): | |
| 100 | 100 | days = days + 29 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,7 @@ def sendportcmd(s, f, port): | |||
| 91 | 91 | hostname = gethostname() | |
| 92 | 92 | hostaddr = gethostbyname(hostname) | |
| 93 | 93 | hbytes = string.splitfields(hostaddr, '.') | |
| 94 | - pbytes = [repr(port/256), repr(port%256)] | ||
| 94 | + pbytes = [repr(port//256), repr(port%256)] | ||
| 95 | 95 | bytes = hbytes + pbytes | |
| 96 | 96 | cmd = 'PORT ' + string.joinfields(bytes, ',') | |
| 97 | 97 | s.send(cmd + '\r\n') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,15 +35,15 @@ def __init__(self, n, bitmap = None): | |||
| 35 | 35 | ||
| 36 | 36 | # Add background bitmap | |
| 37 | 37 | if bitmap: | |
| 38 | - self.bitmap = c.create_bitmap(width/2, height/2, | ||
| 38 | + self.bitmap = c.create_bitmap(width//2, height//2, | ||
| 39 | 39 | bitmap=bitmap, | |
| 40 | 40 | foreground='blue') | |
| 41 | 41 | ||
| 42 | 42 | # Generate pegs | |
| 43 | 43 | pegwidth = 10 | |
| 44 | - pegheight = height/2 | ||
| 45 | - pegdist = width/3 | ||
| 46 | - x1, y1 = (pegdist-pegwidth)/2, height*1/3 | ||
| 44 | + pegheight = height//2 | ||
| 45 | + pegdist = width//3 | ||
| 46 | + x1, y1 = (pegdist-pegwidth)//2, height*1//3 | ||
| 47 | 47 | x2, y2 = x1+pegwidth, y1+pegheight | |
| 48 | 48 | self.pegs = [] | |
| 49 | 49 | p = c.create_rectangle(x1, y1, x2, y2, fill='black') | |
@@ -57,14 +57,14 @@ def __init__(self, n, bitmap = None): | |||
| 57 | 57 | self.tk.update() | |
| 58 | 58 | ||
| 59 | 59 | # Generate pieces | |
| 60 | - pieceheight = pegheight/16 | ||
| 61 | - maxpiecewidth = pegdist*2/3 | ||
| 60 | + pieceheight = pegheight//16 | ||
| 61 | + maxpiecewidth = pegdist*2//3 | ||
| 62 | 62 | minpiecewidth = 2*pegwidth | |
| 63 | 63 | self.pegstate = [[], [], []] | |
| 64 | 64 | self.pieces = {} | |
| 65 | - x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 | ||
| 65 | + x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2 | ||
| 66 | 66 | x2, y2 = x1+maxpiecewidth, y1+pieceheight | |
| 67 | - dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) | ||
| 67 | + dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1)) | ||
| 68 | 68 | for i in range(n, 0, -1): | |
| 69 | 69 | p = c.create_rectangle(x1, y1, x2, y2, fill='red') | |
| 70 | 70 | self.pieces[i] = p | |
@@ -101,10 +101,10 @@ def report(self, i, a, b): | |||
| 101 | 101 | ||
| 102 | 102 | # Move it towards peg b | |
| 103 | 103 | bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) | |
| 104 | - newcenter = (bx1+bx2)/2 | ||
| 104 | + newcenter = (bx1+bx2)//2 | ||
| 105 | 105 | while 1: | |
| 106 | 106 | x1, y1, x2, y2 = c.bbox(p) | |
| 107 | - center = (x1+x2)/2 | ||
| 107 | + center = (x1+x2)//2 | ||
| 108 | 108 | if center == newcenter: break | |
| 109 | 109 | if center > newcenter: c.move(p, -1, 0) | |
| 110 | 110 | else: c.move(p, 1, 0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments