[Python-3000] struni and the Apple four-character-codes
Alex Holkner
aholkner at cs.rmit.edu.au
Fri Jul 27 02:45:35 CEST 2007
Greg Ewing wrote:
> Ronald Oussoren wrote:
>> No. Four-character-constants are *not* strings or byte arrays, they are
>> integer literals.
>
> Well, in Pascal they were character arrays -- it
> was only when they switched to C that they became
> ints. Conceptually they're still the same thing.
> Python isn't C, and doesn't have to be bound by
> C's limitations.
Regardless of what the situation was in Pascal's time, they are
currently integers.
The order of bytes in the array would need to be adjusted depending on
the machine endianness to be correct.
The C argument passing convention is different for byte arrays than for
integers (presumably the most common use of these constants is to use
them with Apple libraries).
Different constants within the same enumeration are sometimes specified
as decimal integers, and sometimes as character constants. For example,
the QTNewGWorldFromPtr function uses an enumeration which includes
k32BGRAPixelFormat, defined as 'BGRA', and k32ARGBPixelFormat, defined
as 0x20.
Providing a convenience str() method may be handy, but the internal
representation must be integer.
Alex.
More information about the Python-3000
mailing list