diff options
author | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
commit | 70a6b49821a3226f55e9716f32d802d06640cb89 (patch) | |
tree | 3c8ca10c1fa09e025bd266cf855a00d7d96c55aa /Demo/sockets | |
parent | ecfeb7f095dfd9c1c8929bf3df858ee35e0d9e9e (diff) | |
download | cpython-70a6b49821a3226f55e9716f32d802d06640cb89.zip cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.gz cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.bz2 |
Replace backticks with repr() or "%r"
From SF patch #852334.
Diffstat (limited to 'Demo/sockets')
-rwxr-xr-x | Demo/sockets/broadcast.py | 2 | ||||
-rwxr-xr-x | Demo/sockets/ftp.py | 2 | ||||
-rwxr-xr-x | Demo/sockets/gopher.py | 24 | ||||
-rwxr-xr-x | Demo/sockets/mcast.py | 4 | ||||
-rwxr-xr-x | Demo/sockets/radio.py | 2 | ||||
-rwxr-xr-x | Demo/sockets/telnet.py | 2 | ||||
-rwxr-xr-x | Demo/sockets/udpecho.py | 4 | ||||
-rw-r--r-- | Demo/sockets/unicast.py | 2 | ||||
-rw-r--r-- | Demo/sockets/unixclient.py | 2 |
9 files changed, 22 insertions, 22 deletions
diff --git a/Demo/sockets/broadcast.py b/Demo/sockets/broadcast.py index a02b081..010162c 100755 --- a/Demo/sockets/broadcast.py +++ b/Demo/sockets/broadcast.py @@ -10,7 +10,7 @@ s.bind(('', 0)) s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) while 1: - data = `time.time()` + '\n' + data = repr(time.time()) + '\n' s.sendto(data, ('<broadcast>', MYPORT)) time.sleep(2) diff --git a/Demo/sockets/ftp.py b/Demo/sockets/ftp.py index 8260c52..9e1d5a1 100755 --- a/Demo/sockets/ftp.py +++ b/Demo/sockets/ftp.py @@ -91,7 +91,7 @@ def sendportcmd(s, f, port): hostname = gethostname() hostaddr = gethostbyname(hostname) hbytes = string.splitfields(hostaddr, '.') - pbytes = [`port/256`, `port%256`] + pbytes = [repr(port/256), repr(port%256)] bytes = hbytes + pbytes cmd = 'PORT ' + string.joinfields(bytes, ',') s.send(cmd + '\r\n') diff --git a/Demo/sockets/gopher.py b/Demo/sockets/gopher.py index a2ab3a2..4e1cb30 100755 --- a/Demo/sockets/gopher.py +++ b/Demo/sockets/gopher.py @@ -75,10 +75,10 @@ def get_menu(selector, host, port): typechar = line[0] parts = string.splitfields(line[1:], TAB) if len(parts) < 4: - print '(Bad line from server:', `line`, ')' + print '(Bad line from server: %r)' % (line,) continue if len(parts) > 4: - print '(Extra info from server:', parts[4:], ')' + print '(Extra info from server: %r)' % (parts[4:],) parts.insert(0, typechar) list.append(parts) f.close() @@ -154,17 +154,17 @@ def browse_menu(selector, host, port): list = get_menu(selector, host, port) while 1: print '----- MENU -----' - print 'Selector:', `selector` + print 'Selector:', repr(selector) print 'Host:', host, ' Port:', port print for i in range(len(list)): item = list[i] typechar, description = item[0], item[1] - print string.rjust(`i+1`, 3) + ':', description, + print string.rjust(repr(i+1), 3) + ':', description, if typename.has_key(typechar): print typename[typechar] else: - print '<TYPE=' + `typechar` + '>' + print '<TYPE=' + repr(typechar) + '>' print while 1: try: @@ -221,7 +221,7 @@ def browse_textfile(selector, host, port): def browse_search(selector, host, port): while 1: print '----- SEARCH -----' - print 'Selector:', `selector` + print 'Selector:', repr(selector) print 'Host:', host, ' Port:', port print try: @@ -240,9 +240,9 @@ def browse_search(selector, host, port): # "Browse" telnet-based information, i.e. open a telnet session def browse_telnet(selector, host, port): if selector: - print 'Log in as', `selector` + print 'Log in as', repr(selector) if type(port) <> type(''): - port = `port` + port = repr(port) sts = os.system('set -x; exec telnet ' + host + ' ' + port) if sts: print 'Exit status:', sts @@ -307,18 +307,18 @@ def open_savefile(): try: p = os.popen(cmd, 'w') except IOError, msg: - print `cmd`, ':', msg + print repr(cmd), ':', msg return None - print 'Piping through', `cmd`, '...' + print 'Piping through', repr(cmd), '...' return p if savefile[0] == '~': savefile = os.path.expanduser(savefile) try: f = open(savefile, 'w') except IOError, msg: - print `savefile`, ':', msg + print repr(savefile), ':', msg return None - print 'Saving to', `savefile`, '...' + print 'Saving to', repr(savefile), '...' return f # Test program diff --git a/Demo/sockets/mcast.py b/Demo/sockets/mcast.py index cc7a7e0..71bcc75 100755 --- a/Demo/sockets/mcast.py +++ b/Demo/sockets/mcast.py @@ -38,7 +38,7 @@ def sender(flag): ttl = struct.pack('b', 1) # Time-to-live s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) while 1: - data = `time.time()` + data = repr(time.time()) ## data = data + (1400 - len(data)) * '\0' s.sendto(data, (mygroup, MYPORT)) time.sleep(1) @@ -53,7 +53,7 @@ def receiver(): while 1: data, sender = s.recvfrom(1500) while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's - print sender, ':', `data` + print sender, ':', repr(data) # Open a UDP socket, bind it to a port and select a multicast group diff --git a/Demo/sockets/radio.py b/Demo/sockets/radio.py index 6131d40..b68a4ec 100755 --- a/Demo/sockets/radio.py +++ b/Demo/sockets/radio.py @@ -10,5 +10,5 @@ s.bind(('', MYPORT)) while 1: data, wherefrom = s.recvfrom(1500, 0) - sys.stderr.write(`wherefrom` + '\n') + sys.stderr.write(repr(wherefrom) + '\n') sys.stdout.write(data) diff --git a/Demo/sockets/telnet.py b/Demo/sockets/telnet.py index ee7c43b..d86cbeb 100755 --- a/Demo/sockets/telnet.py +++ b/Demo/sockets/telnet.py @@ -53,7 +53,7 @@ def main(): try: s.connect((host, port)) except error, msg: - sys.stderr.write('connect failed: ' + `msg` + '\n') + sys.stderr.write('connect failed: ' + repr(msg) + '\n') sys.exit(1) # pid = posix.fork() diff --git a/Demo/sockets/udpecho.py b/Demo/sockets/udpecho.py index 4410165..720cfe1 100755 --- a/Demo/sockets/udpecho.py +++ b/Demo/sockets/udpecho.py @@ -37,7 +37,7 @@ def server(): print 'udp echo server ready' while 1: data, addr = s.recvfrom(BUFSIZE) - print 'server received', `data`, 'from', `addr` + print 'server received %r from %r' % (data, addr) s.sendto(data, addr) def client(): @@ -58,6 +58,6 @@ def client(): break s.sendto(line, addr) data, fromaddr = s.recvfrom(BUFSIZE) - print 'client received', `data`, 'from', `fromaddr` + print 'client received %r from %r' % (data, fromaddr) main() diff --git a/Demo/sockets/unicast.py b/Demo/sockets/unicast.py index 1e9caeb..0a30f35 100644 --- a/Demo/sockets/unicast.py +++ b/Demo/sockets/unicast.py @@ -9,7 +9,7 @@ s = socket(AF_INET, SOCK_DGRAM) s.bind(('', 0)) while 1: - data = `time.time()` + '\n' + data = repr(time.time()) + '\n' s.sendto(data, ('', MYPORT)) time.sleep(2) diff --git a/Demo/sockets/unixclient.py b/Demo/sockets/unixclient.py index a0d80f6..cccd617 100644 --- a/Demo/sockets/unixclient.py +++ b/Demo/sockets/unixclient.py @@ -7,4 +7,4 @@ s.connect(FILE) s.send('Hello, world') data = s.recv(1024) s.close() -print 'Received', `data` +print 'Received', repr(data) |