Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'jan': 0.12; "b''": 0.16; 'expression,': 0.16; 'itself,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'roy': 0.16; 'splitting': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'pieces': 0.19; 'result.': 0.19; 'command': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'bytes': 0.24; 'instance,': 0.24; 'earlier': 0.24; 'skip:" 30': 0.26; 'this:': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'needed.': 0.30; 'file': 0.32; '(most': 0.33; 'problem': 0.35; 'test': 0.35; 'add': 0.35; 'sequence': 0.36; 'error.': 0.37; 'expected': 0.38; 'sometimes': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'new': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; 'apart': 0.72; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Odd-length string Date: Sun, 06 Oct 2013 15:50:38 -0400 References: <0f1b6cd6-3025-4bdc-8f80-73a51a7ed241@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381089050 news.xs4all.nl 15939 [2001:888:2000:d::a6]:46926 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56280 On 10/6/2013 10:37 AM, markotaht@gmail.com wrote: > NEw problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in = > print("Key-" + str(v=C3=B5ti) + ": " + str("".join(tulemus2))) > TypeError: sequence item 0: expected str instance, bytes found If ''.join(iterable_of_strings) executes, the result is a string and str = would not be needed. If you try "".join(tulemus2) by itself, you will see the same error. > If i take away the join command i get this: Key-00000000: [b'u', b'o',= b'\x00', b'\x1d', b' ', b'|', b'N', b'\x0f', b'9', b'j', b'K', b'J', b'&= ', b'#', b'A', b'K', b'5', b'k', b'_', b'\x1e', b',', b'j', b'\x0c', b'\x= 08', b'i', b'(', b'\x06', b'\\', b'r', b'3', b'\x1f', b'V', b's', b'9', b= '\x1d'] Since tulemus2 is an iterable_of_bytes, you must join with bytes b'' and = call str on the result. So just add the b prefix. What Roy tried to say to you earlier is that when you get an error in a=20 expression, and you do not understand *exactly* where in the expression=20 the error is, pull the expression apart and test the pieces=20 individually. This sometimes includes splitting print(expression) # into s=3Dexpression print(s) --=20 Terry Jan Reedy