Stephen J. Turnbull added the comment:
I'm thinking this may be overengineering, but I may as well post it and find
out for sure. :-) Is it worth encapsulating MIME types? They're "really"
pairs as far as mail handling applications are concerned, but they have a
string representation. So
MacPorts 16:29$ python3.3
Python 3.3.2 (default, May 21 2013, 11:48:51)
>>> from collections import namedtuple
>>> class MIMEType(namedtuple('MIMETYPE', 'type subtype')):
... def __str__(self):
... return "{0}/{1}".format(self.type, self.subtype)
...
>>> mt = MIMEType('text', 'plain')
>>> str(mt)
'text/plain'
>>> t, s = mt
>>> print('type =', t, 'subtype =', s)
type = text subtype = plain
>>>
Obviously there needs to be a constructor that handles the 'type/sub'
represention.
----------
nosy: +sjt
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18891>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com