Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'builtin': 0.09; 'skip:> 40': 0.09; 'subject:How': 0.10; "'rb')": 0.16; 'callable': 0.16; 'file.read()': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'function?': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'char': 0.24; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'generally': 0.29; 'second,': 0.31; 'something': 0.35; 'version': 0.36; 'module.': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'two': 0.37; 'received:211': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'content-disposition:inline': 0.62; 'email addr:gmail.com': 0.63; 'name': 0.63; 'janice': 0.84; 'madness': 0.84; 'recover': 0.91 Date: Fri, 14 Nov 2014 18:46:09 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: How to recover bytes function? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <44f58abf-35a8-4741-8b7c-7eabe99a326d@googlegroups.com> User-Agent: Mutt/1.5.23 (2014-03-12) References: <44f58abf-35a8-4741-8b7c-7eabe99a326d@googlegroups.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=BdjhjNd2 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=J0QyKEt1u0cA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=xqDeW7FdAAAA:8 a=zaSWbuxqpE81VUMsGQAA:9 a=CjuIK1q_8ugA:10 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415951174 news.xs4all.nl 2873 [2001:888:2000:d::a6]:58251 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3753 X-Received-Body-CRC: 1222153034 Xref: csiph.com comp.lang.python:80747 On 13Nov2014 14:32, satishmlmlml@gmail.com wrote: >file = open('data.bin', 'rb') >bytes = file.read() >bytes >b'\x00\x00\x00\x02spam\x00\x03?\x9d\xf3\xb6' >records = [bytes([char] * 8) for char in b'spam'] >TypeError: 'bytes' object is not callable > >How to recover bytes function? The best way is not to use "bytes" for something else when you know you will be using the builtin version as well. Using the same name for two things is generally a bad idea. The second, and worse, way is to see the documentation for the "builtins" module. Cheers, Cameron Simpson Madness takes its toll. Please have exact change. - Janice Hanes