Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Everything you did not want to know about Unicode in Python 3
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Ian Kelly, post: 5159645"] No, that part is perfectly fine. This is exactly what the shutil module is meant for: providing shell-like operations. Although in this case the copyfileobj function is quite simple (have yourself a look at the source -- it just reads from one file and writes to the other in a loop), in general the Pythonic thing is to avoid reinventing the wheel. And since it's so simple, it shouldn't be hard to see that the use of the shutil module has nothing to do with the Unicode woes here. The crux of the issue is that a general-purpose command like cat typically can't know the encoding of its input and can't assume anything about it. In fact, there may not even be an encoding; cat can be used with binary data. The only non-destructive approach then is to copy the binary data straight from the source to the destination with no decoding steps at all, and trust the user to ensure that the destination will be able to accommodate the source encoding. Because Python 3 presents stdin and stdout as text streams however, it makes them more difficult to use with binary data, which is why Armin sets up all that extra code to make sure his file objects are binary. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Everything you did not want to know about Unicode in Python 3
Top