[Python-3000] Fix imghdr module for bytes

Adam Olsen rhamph at gmail.com
Sun Aug 12 21:53:27 CEST 2007


On 8/12/07, Paul Moore <p.f.moore at gmail.com> wrote:
> On 11/08/07, Adam Olsen <rhamph at gmail.com> wrote:
> > Try h[0:1] == b'P'. Slicing will ensure it stays as a bytes object,
> > rather than just giving the integer it contains.
>> Ugh. Alternatively, h[0] == ord('P') should work.
>> Unless you're writing source in EBCDIC (is that allowed?).

I doubt it, but if it was it should be translated to unicode upon
loading and have no effect on the semantics.
> All of the alternatives seem somewhat ugly. While I agree with the
> idea that the bytes should be kept clean & simple, we seem to be
> finding a few non-optimal corner cases. It would be a shame if the
> bytes type turned into a Python 3.0 wart from day 1...

I don't think this behaviour change is a problem. It's just a bit
surprising and something that has to be learned when you switch to
3.0. It matches list behaviour and in the end will reduce the
concepts needed to use the language.
> Would it be worth keeping a wiki page of the bytes type "idioms" that
> are needed, as people discover them? Putting them all in one place
> might give a better feel as to whether there is a real problem to
> address.

-- 
Adam Olsen, aka Rhamphoryncus


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /