Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'attribute': 0.07; 'encoded': 0.07; 'skip:u 30': 0.07; 'string': 0.09; 'bytes,': 0.09; 'bytes.': 0.09; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'variant': 0.09; 'emanuele': 0.16; 'encoding.': 0.16; 'ignoring': 0.16; 'opposite': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'header:X -Complaints-To:1': 0.27; 'array': 0.29; 'code': 0.31; '"",': 0.31; 'produces': 0.31; 'writes:': 0.31; 'file': 0.32; '(most': 0.33; 'subject:from': 0.34; 'subject: (': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'usual': 0.35; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'che': 0.60; '8bit%:21': 0.69; '8bit%:92': 0.71; '8bit%:100': 0.72; 'no:': 0.84; 'quando': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lele Gaifax Subject: Re: Changing filenames from Greeklish => Greek (subprocess complain) Date: Sun, 09 Jun 2013 11:20:58 +0200 Organization: Nautilus Entertainments References: <7d8da6c9-fb92-4329-b207-4280f29ba664@googlegroups.com> <20130608024931.GA77888@cskk.homeip.net> <51B37173.9060601@gmail.com> <3fbb5d0e-51fb-4aed-b829-8388304a9885@googlegroups.com> <51b4249d$0$30001$c3e8da3$5496439d@news.astraweb.com> <9a0ea98b-f37b-48da-9933-e2caf6fdfdff@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 151.62.123.243 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:GCw0vw73YXLwLVIyb1trQpO8eqc= 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370769662 news.xs4all.nl 15917 [2001:888:2000:d::a6]:51177 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47441 Νικόλαος Κούρας writes: > Τη Κυριακή, 9 Ιουνίου 2013 11:55:43 π.μ. UTC+3, ο χρήστης Lele Gaifax έγραψε: >> Uhm, no: "encode" transforms a Unicode string into an array of bytes, >> "decode" does the opposite transformation. You cannot do the former on >> an "arbitrary" array of bytes: >> >> >>> s = "νίκος" >> >>> utf8_bytes = s.encode('utf-8') >> >>> greek_bytes = utf8_bytes.encode('iso-8869-7') >> Traceback (most recent call last): >> File "", line 1, in >> AttributeError: 'bytes' object has no attribute 'encode' > > So something encoded into bytes cannot be re-encoded to some other bytes. > > How about a string i wonder? > s = "νίκος" > what_are these_bytes = s.encode('iso-8869-7').encode(utf-8') Ignoring the usual syntax error, this is just a variant of the code I posted: “s.encode('iso-8869-7')” produces a bytes instance which *cannot* be "re-encoded" again in whatever encoding. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.