some problems for an introductory python test

Cameron Simpson cs at cskk.id.au
Thu Aug 12 20:12:12 EDT 2021


On 12Aug2021 12:09, Hope Rouselle <hrouselle at jevedi.com> wrote:
>Chris Angelico <rosuav at gmail.com> writes:
>> [...] Plus, it had this fancy
>> concept of "extended attributes"; on older systems (like MS-DOS's
>> "FAT" family), a file might be Read-Only, Hidden, a System file, or
>> needing to be Archived, and that was it - but on HPFS, you could
>> attach arbitrary data like "File type: DeScribe Word Processor" or
>> "Double click action: Run CASMake.cmd". This allowed the GUI to store
>> all kinds of information *on the file itself* instead of needing
>> hidden files (or, in Windows' case, the registry) to track that kind
>> of thing.
>
>Yeah, that's kinda nice.  Isn't that a UNIX design?  A file is a
>sequence of bytes?  Users decide what to put in them?

Yes, but extended attributes are outside the file data. They're very 
common on UNIX platforms these days. You can label arbitrary files with 
a file type or whatever else. (There are platform specific limitations, 
and even the OS API to deal with them is platform specific - Linux is 
different to FreeBSD is different to MacOS.)

Also, Python has support for accessing these off-to-the-side data:

    https://docs.python.org/3/library/os.html#linux-extended-attributes

Labelled "Linux" but also available for FreeBSD and IIRC OpenBSD. You do 
of course need filesystem support - FAT32 for example would not work 
with this - the filesystem needs a way to store these things. But ext4 
and XFS on Linux, HFS+ on MacOS etc all support this.

I've even got a CPython branch where I'm implementing the MacOS backend 
for these calls, a little stalled.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list