[New-bugs-announce] [issue34926] Adding "mine_type" method to pathlib.Path
YoSTEALTH
report at bugs.python.org
Mon Oct 8 02:07:24 EDT 2018
New submission from YoSTEALTH <ritesh at stealthcentral.com>:
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 <report at bugs.python.org>
<https://bugs.python.org/issue34926>
_______________________________________
More information about the New-bugs-announce
mailing list