Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56280
| 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 | <python-python-list@m.gmane.org> |
| 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 <tjreedy@udel.edu> |
| Subject | Re: Odd-length string |
| Date | Sun, 06 Oct 2013 15:50:38 -0400 |
| References | <0f1b6cd6-3025-4bdc-8f80-73a51a7ed241@googlegroups.com> <dc7e43a4-2f40-4275-8754-7e947f886fd9@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 | <dc7e43a4-2f40-4275-8754-7e947f886fd9@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.794.1381089050.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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 <module>
> print("Key-" + str(võti) + ": " + 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'\x08', 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
expression, and you do not understand *exactly* where in the expression
the error is, pull the expression apart and test the pieces
individually. This sometimes includes splitting
print(expression) # into
s=expression
print(s)
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Odd-length string markotaht@gmail.com - 2013-10-06 06:10 -0700
Re: Odd-length string Roy Smith <roy@panix.com> - 2013-10-06 09:46 -0400
Re: Odd-length string Peter Otten <__peter__@web.de> - 2013-10-06 16:31 +0200
Re: Odd-length string markotaht@gmail.com - 2013-10-06 07:37 -0700
Re: Odd-length string Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 15:56 +0100
Re: Odd-length string Terry Reedy <tjreedy@udel.edu> - 2013-10-06 15:50 -0400
Re: Odd-length string Piet van Oostrum <piet@vanoostrum.org> - 2013-10-06 20:59 -0400
csiph-web