ok so i'm in the market for a data file and i see python has a tomllib now. i've never actually used toml for anything but i thought i'd give it a whirl, why not.
first observation: you can't make, like, verbose lists. like disregard i suck cocks, [foo] is always a dict key, never a list entry. well that kind of sucks but ok.[[foo]] headers make lists, thank u @porglezomp
but then i see tomllib.loads takes a str, whereas tomllib.load takes a file specifically opened in binary mode. huh what
i check the stdlib source and
def load(fp: BinaryIO, /, *, parse_float: ParseFloat = float) -> dict[str, Any]:
"""Parse TOML from a binary file object."""
b = fp.read()
try:
s = b.decode()
except AttributeError:
raise TypeError(
"File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`"
) from None
return loads(s, parse_float=parse_float)
????????????
who wrote this like this. WHy is this lik ethis
edit: omg the spec even LITERALLY SAYS
A TOML file must be a valid UTF-8 encoded Unicode document.
so why is the stdlib using the default encoding?? ?? ? ???? ? ?
wait it's not, bytes.decode() defaults to utf-8? that is news to me. ok so the whole idea is to enforce utf8 on a toml file. Well then nevermind this entire goddamn post