what does := means simply?
bartc
bc at freeuk.com
Fri May 18 20:55:39 EDT 2018
On 19/05/2018 01:00, Chris Angelico wrote:
> On Sat, May 19, 2018 at 7:53 AM, bartc <bc at freeuk.com> wrote:
>> I've worked with text files for 40 years. Now Python is telling me I've been
>> doing it wrong all that time!
>>
>> Look at the original code I posted from which this Python was based. That
>> creates a file - just a file - without worrying about whether it's text or
>> binary. Files are just collections of bytes, as far as the OS is concerned.
>>
>> So what could be more natural than writing a byte to the end of a file?
>
> So, you create a file without worrying about whether it's text or
> binary, and you add a byte to the end of the file. That means you're
> treating it as a binary file, not as a text file. Do you understand
> that?
Well I /don't/ worry about, but the reason is that long ago I switched
to using binary mode for all files. (My 'createfile' function shown
after my sig shows how it works. It's a thin wrapper around C's fopen,
and it's C that has this thing about text and binary files.)
But in Python, even as a binary file I had some trouble writing to it,
as it's fussy when dealing with strings and bytearrays and bytes and
array.arrays all with their own rules.
--
bartc
global function createfile(name, options="wb") =
if not name.isstring or name="" then
return nil
fi
return fopen(name,options)
end
More information about the Python-list
mailing list