[I18n-sig] Re: [Python-Dev] Pre-PEP: Python Character Model
Fredrik Lundh
fredrik@pythonware.com
Wed, 7 Feb 2001 11:00:03 +0100
martin wrote:
> To take a specific example: What would you change about imp and
> py_compile.py? What is the type of imp.get_magic()? If character
> string, what about this fragment?
>
> import imp
> MAGIC = imp.get_magic()
>
> def wr_long(f, x):
> """Internal; write a 32-bit int to a file in little-endian order."""
> f.write(chr( x & 0xff))
> f.write(chr((x >> 8) & 0xff))
> f.write(chr((x >> 16) & 0xff))
> f.write(chr((x >> 24) & 0xff))
> ...
> fc = open(cfile, 'wb')
> fc.write('\0\0\0\0')
> wr_long(fc, timestamp)
> fc.write(MAGIC)
>
> Would that continue to write the same file that the current version
> writes?
yes (file opened in binary mode, no encoding, no code points above 255)
Cheers /F