Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'binary': 0.07; 'method.': 0.07; 'ascii': 0.09; 'assumed': 0.09; 'integers': 0.09; 'lawrence': 0.09; 'methods,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sequences.': 0.09; 'stored': 0.12; 'language.': 0.14; 'changes': 0.15; '(inclusive)': 0.16; '255': 0.16; 'bytearray': 0.16; 'mutable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'zero,': 0.16; 'language': 0.16; 'split': 0.19; 'header :User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'integer': 0.24; 'interpret': 0.24; 'unicode': 0.24; "haven't": 0.24; 'header:X-Complaints-To:1': 0.27; 'array': 0.29; 'character': 0.29; 'characters': 0.30; 'subject:skip:i 10': 0.31; 'url:python': 0.33; '(e.g.': 0.33; '"the': 0.34; "can't": 0.35; 'operations': 0.35; 'but': 0.35; 'version': 0.36; 'sequence': 0.36; 'done': 0.36; 'method': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'referred': 0.60; 'url:3': 0.61; 'range': 0.61; 'further': 0.61; 'first': 0.61; 'discuss': 0.62; 'our': 0.64 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: bytearray inconsistencies? Date: Sat, 21 Dec 2013 01:06:08 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-30-118.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387587990 news.xs4all.nl 2858 [2001:888:2000:d::a6]:50337 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62460 Quoting from http://docs.python.org/3/library/functions.html#bytearray "The bytearray type is a mutable sequence of integers in the range 0 <= x < 256." Quoting from http://docs.python.org/3/library/stdtypes.html#bytes-methods "Whenever a bytes or bytearray method needs to interpret the bytes as characters (e.g. the is...() methods, split(), strip()), the ASCII character set is assumed (text strings use Unicode semantics). Note - Using these ASCII based methods to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The search operations (in, count(), find(), index(), rfind() and rindex()) all accept both integers in the range 0 to 255 (inclusive) as well as bytes and byte array sequences. Changed in version 3.3: All of the search methods also accept an integer in the range 0 to 255 (inclusive) as their first argument." I don't understand why the docs talk about "a mutable sequence of integers" but then discuss "needs to interpret the bytes as characters". Further I don't understand why the changes done in 3.3 referred to above haven't also been applied to (say) the split method. If I can call find to look for a zero, why can't I split on it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence