Movatterモバイル変換
[0]ホーム
[Python-Dev] buffer('abc') == 'abc' is False ?!
M.-A. Lemburgmal@lemburg.com
Wed, 16 Oct 2002 17:24:20 +0200
Guido van Rossum wrote:>>>>* signals "this data is binary data">>>>* compares just fine to strings>>>>* gets accepted by all APIs which use the buffer interface to>>>> access the data>>>>* has a C API which can be used in extensions>>>>* is available in Python 2.1.x and up>>>>>>>>>I believe the string type meets all these requirements.>>>>Except one which was implicit: how to tell binary data from>>text data. This information can sometimes be deduced>>from the string content provided you know what text data>>means to you, but this doesn't always work, since sometimes>>binary data happens to look like text data (ie. use only>>character ordinals as data bytes).>> I don't understand why you need to signal "this is binary data" while> at the same time you want to be able to compare to strings.Because I use buffer objects to wrap string data to say"this is binary data" to a database. When fetching thesame data back from the database I return a string andI found the quirk mentioned in the subject while writinga unit test for this. It's not a showstopper.The above just was a hint not to deprecate the bufferobject until we've come up with a decent replacementthat's easy to adapt in existing code.-- Marc-Andre LemburgCEO eGenix.com Software GmbH_______________________________________________________________________eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...Python Consulting:http://www.egenix.com/Python Software:http://www.egenix.com/files/python/
[8]ページ先頭