what does := means simply?

Peter J. Holzer hjp-python at hjp.at
Sat May 19 07:33:17 EDT 2018


On 2018-05-19 11:33:26 +0100, bartc wrote:
> 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.

"Not" or "Now"?

Yesterday you claimed that you worked with them for 40 years.

> 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').

(EBCDIC '7' is actually 0xF7)

I think the simplest way would be perform the calculation by hand
(new_value = old_value * 10 + next_byte - 0x30). At least in a language
which lets me process individual bytes easily. That would even work on
both ASCII and EBCDIC based systems (and on every other platform, too).


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

No need to acknowledge anything. Yes. the inventor of the format was
obviously thinking in ASCII, but to implement it you don't have to do
that. Just read bytes and extract information from them.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20180519/1fb83023/attachment.sig>


More information about the Python-list mailing list