File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change 3
3
'''Item 3 from Effective Python'''
4
4
5
5
import logging
6
- from pprint import pprint
7
- from sys import stdout as STDOUT
8
6
9
7
10
8
# Example 1
11
9
def to_str (bytes_or_str ):
12
- '''In Python 3, you’ ll need one method that takes a str or bytes and
10
+ '''In Python 3, you' ll need one method that takes a str or bytes and
13
11
always returns a str .'''
14
12
if isinstance (bytes_or_str , bytes ):
15
13
value = bytes_or_str .decode ('utf-8' )
@@ -23,7 +21,7 @@ def to_str(bytes_or_str):
23
21
24
22
# Example 2
25
23
def to_bytes (bytes_or_str ):
26
- '''You’ ll need another method that takes a str or bytes and always
24
+ '''You' ll need another method that takes a str or bytes and always
27
25
returns a bytes .'''
28
26
if isinstance (bytes_or_str , str ):
29
27
value = bytes_or_str .encode ('utf-8' )
You can’t perform that action at this time.
0 commit comments