[issue18535] termios.tcgetattr should return namedtuple
Amaury Forgeot d'Arc
report at bugs.python.org
Tue Jul 23 14:44:09 CEST 2013
Amaury Forgeot d'Arc added the comment:
namedtuple has a _replace method, but I agree that it would be an incompatible change. "namedlist" someone?
class tcattributes(object):
__slots__ = ['iflag', 'oflag', 'cflag', 'lflag', 'ispeed', 'ospeed', 'cc']
def __new__(cls, values):
self = object.__new__(cls)
for attr, value in zip(cls.__slots__, values):
setattr(self, attr, value)
return self
def __getitem__(self, index):
return getattr(self, self.__slots__[index])
----------
nosy: +amaury.forgeotdarc
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18535>
_______________________________________
More information about the Python-bugs-list
mailing list