[Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Ram Rachum
Hi everyone, Take a look at this question: http://stackoverflow.com/questions/16122435/python-3-how-do-i-use-bytes-to-bytes-and-string-to-string-encodings/16122472?noredirect=1#comment23034787_16122472 Is there really no way to use base64 that's as short as: b'whatever'.encode('base64')

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Victor Stinner
Hi, Your question is discussed since 4 years in the following issue: http://bugs.python.org/issue7475 The last proposition is to add transform() and untransform() methods to bytes and str types. But nobody implemented the idea. If I remember correctly, the missing point is how to define which

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Calvin Spealman
if two lines is cumbersome, you're in for a cumbersome life a programmer. On Apr 22, 2013 7:31 AM, Ram Rachum r...@rachum.com wrote: Hi everyone, Take a look at this question:

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Paul Moore
On 22 April 2013 12:39, Calvin Spealman ironfro...@gmail.com wrote: if two lines is cumbersome, you're in for a cumbersome life a programmer. One of which is essentially Python's equivalent of a declaration... Paul ___ Python-Dev mailing list

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Devin Jeanpierre
On Mon, Apr 22, 2013 at 7:39 AM, Calvin Spealman ironfro...@gmail.com wrote: if two lines is cumbersome, you're in for a cumbersome life a programmer. Other encodings are either missing completely from the stdlib, or have corrupted behavior. For example, string_escape is gone, and unicode_escape

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Oleg Broytman
On Mon, Apr 22, 2013 at 09:50:14AM -0400, Devin Jeanpierre jeanpierr...@gmail.com wrote: unicode_escape doesn't make any sense anymore -- python code is text, not bytes, so why does 'abc'.encode('unicode_escape') return bytes? AFAIU the situation is simple: unicode.encode(encoding) returns

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Stephen J. Turnbull
Devin Jeanpierre writes: why does 'abc'.encode('unicode_escape') return bytes? Duck-typing: encode always turns unicode into bytes. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread R. David Murray
On Mon, 22 Apr 2013 09:50:14 -0400, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Mon, Apr 22, 2013 at 7:39 AM, Calvin Spealman ironfro...@gmail.com wrote: if two lines is cumbersome, you're in for a cumbersome life a programmer. Other encodings are either missing completely from the

Re: [Python-Dev] cpython: Simplify the code of get_attrib_from_keywords somewhat.

2013-04-22 Thread Serhiy Storchaka
On 22.04.13 15:52, eli.bendersky wrote: http://hg.python.org/cpython/rev/c9674421d78e changeset: 83494:c9674421d78e user:Eli Bendersky eli...@gmail.com date:Mon Apr 22 05:52:16 2013 -0700 summary: Simplify the code of get_attrib_from_keywords somewhat. -

Re: [Python-Dev] cpython: Simplify the code of get_attrib_from_keywords somewhat.

2013-04-22 Thread Eli Bendersky
On Mon, Apr 22, 2013 at 10:13 AM, Serhiy Storchaka storch...@gmail.comwrote: On 22.04.13 15:52, eli.bendersky wrote: http://hg.python.org/cpython/**rev/c9674421d78ehttp://hg.python.org/cpython/rev/c9674421d78e changeset: 83494:c9674421d78e user:Eli Bendersky eli...@gmail.com date:

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Greg Ewing
Victor Stinner wrote: The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define which types are supported by a codec Also, for any given codec, which direction is transform and which is

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread R. David Murray
On Tue, 23 Apr 2013 11:16:20 +1200, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Victor Stinner wrote: The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define which types are supported

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Guido van Rossum
--Guido van Rossum (sent from Android phone) On Apr 22, 2013 6:09 PM, R. David Murray rdmur...@bitdance.com wrote: On Tue, 23 Apr 2013 11:16:20 +1200, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Victor Stinner wrote: The last proposition is to add transform() and untransform() methods

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Steven D'Aprano
On 23/04/13 09:16, Greg Ewing wrote: Victor Stinner wrote: The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define which types are supported by a codec Also, for any given codec, which

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Donald Stufft
On Apr 22, 2013, at 10:04 PM, Steven D'Aprano st...@pearwood.info wrote: On 23/04/13 09:16, Greg Ewing wrote: Victor Stinner wrote: The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Guido van Rossum
On Mon, Apr 22, 2013 at 7:04 PM, Steven D'Aprano st...@pearwood.info wrote: As others have pointed out in the past, repeatedly, the codec system is completely general and can transform bytes-bytes and text-text just as easily as bytes-text. Or indeed any bijection, as the docs for 2.7 point

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Lennart Regebro
On Tue, Apr 23, 2013 at 4:04 AM, Steven D'Aprano st...@pearwood.info wrote: As others have pointed out in the past, repeatedly, the codec system is completely general and can transform bytes-bytes and text-text just as easily as bytes-text. Yes, but the encode()/decode() methods are not, and

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Fábio Santos
Using decode() and encode() would break that predictability. But someone suggested the use of transform() and untransform() instead. That would clarify that the transformation is bytes bytes and Unicode string Unicode string. On 23 Apr 2013 05:50, Lennart Regebro rege...@gmail.com wrote: On