email.message_from_file & quoted printable
Cameron Simpson
cs at cskk.id.au
Fri Dec 24 17:41:24 EST 2021
On 24Dec2021 09:31, Skip Montanaro <skip.montanaro at gmail.com> wrote:
>Cameron> Try decode=True.
>
>Skip> :dopeslap: Thanks. Never been all that consistent reading documentation.
>
>The more I think about it, the more I think maybe my lack of
>documentation reading wasn't all that unreasonable. The content
>transfer encoding and charset are properties of the message as a
>whole. Iexpected the internal form of the message body to be already
>decoded. Am I missing some key bit of perspective here?
That sometimes you want the raw content as it was in the file? That if
you have that choice (decoded or raw) the default should be False, as it
does less?
Aside: a personal design criterion of mine is that default values should
be False or zero or empty - leaving off an optional parameter _should_
be like setting it to "falseish". I'm prepared to reach for a thesaurus
to achieve that goal.
Returning to the issue: you had a method that gives you the main
payload. It seemed to be raw. You wanted the decoded form, and thought
that'd be a pretty common thing to want. So it is well worth a look at
the function docs to see if that entirely reasonable thing was
convenient.
That we my _first_ instinct - I've never used get_payload(), myself, and
I've written my own complete mailfiler :-)
Really, if a function isn't doing what you want you should always read
the docs for that function specificly, even if you don't want to read
the entire module docs (which is a big ask).
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list