what does := means simply?

bartc bc at freeuk.com
Sat May 19 06:33:26 EDT 2018


On 19/05/2018 02:26, Chris Angelico wrote:
> On Sat, May 19, 2018 at 11:10 AM, bartc <bc at freeuk.com> wrote:

>> The .ppm (really .pbm) file which was the subject of this sub-thread has its
>> header defined using ASCII. I don't think an EBCDIC 'P4' etc will work.
>>
> 
> "Defined using ASCII" is a tricky concept. There are a number of file
> formats that have certain parts defined because of ASCII mnemonics,
> but are actually defined numerically. The PNG format begins with the
> four bytes 89 50 4E 47, chosen because three of those bytes represent
> the letters "PNG" in ASCII. But it's defined as those byte values. The
> first three represent "i&+" in EBCDIC, and that would be just as
> valid, because you get the correct bytes.
> 
> Your file contains bytes. Not text.

Not you understand why some of us don't bother with 'text mode' files.

However if you have an actual EBCDIC system and would to read .ppm 
files, then you will have trouble reading the numeric parameters as they 
are expressed using sequences of ASCII digits.

The simplest way would be to pass each byte through an ASCII to EBCDIC 
lookup table (so that code 0x37 for ASCII '7', which is EOT in EBCDIC, 
is turned into 0xF8 which is EBCDIC '7').

But then you are acknowledging the file is, in fact, ASCII.

-- 
bartc



More information about the Python-list mailing list