[Python-3000] PEP 3138- String representation in Python 3000
"Martin v. Löwis"
martin at v.loewis.de
Mon May 19 23:03:23 CEST 2008
> They are convenience methods to the codecs registry
> with the added benefit of applying type checks which the codecs
> registry does not guarantee since it only manages codecs.
I argue that things that could be parameters to .transform don't
belong into the codec registry in the first place.
> Of course, you can write everything directly against the codec
> registry or some other specialized interface, but that's not
> really what we're after here.
No need for writing directly against the codec registry.
Using some other specialized interface: yes, Yes, YES!
> Motivation: When was the last time you used a gzip compression
> option (ie. yes there are options, but do you use them in the
> general use case) ?
Depends on what I do: when I invoke gzip from the command line,
I pass -9 all the time, as a habit.
Or did you mean "in Python"? It's a long time that I needed to
use the gzip module at all; and the last few times, I suppose
it was always through the tarfile module.
I use gzip so rarely that I find it wasteful that it gets its
own shortcut. If I had a (half-serious) wish for a string
method shortcut, it would be
"GET / HTTP/1.0\r\n\r\n".sendto("foo.bar.com", 80)
Perhaps I should write a codec for that:
"GET / HTTP/1.0\r\n\r\n".encode("http:foo.bar.com")
which sends the request and returns the response :-)
> Can you write code that applies UU encoding
> without looking up the details in the documentation (ie. there
> is a module for doing UU-encoding in the stdlib, but what's it's
> name, what's the function, does it need extra logic) ?
You mean, without looking into the HTML documentation? Sure enough.
"import uu" I remember, then I do help(uu), scroll to the end.
If you can't remember that the module's name is uu, then you probably
can't remember the codec, either:
py> "foo".encode("uuencode")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
LookupError: unknown encoding: uuencode
Regards,
Martin
More information about the Python-3000
mailing list