New submission from YoSTEALTH <[email protected]>:
How about adding basic "mime_type" method to "pathlib.Path" ?
Code would do something like:
import mimetypes
def mime_type(name):
"""Mime-type of the file."""
find = name.rfind('.')
ext = '' if find == -1 else name[find:]
return mimetypes.types_map.get(ext, 'application/octet-stream')
Users would use it like so:
import pathlib
file = pathlib.Path('hello_world.py')
print(file.mime_type) # 'text/x-python'
----------
components: Extension Modules
messages: 327323
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Adding "mine_type" method to pathlib.Path
type: enhancement
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34926>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com