New submission from poornaprudhvi <poornagur...@gmail.com>: >>> from collections import namedtuple >>> sample = namedtuple('Name','a','b','c')
This is returning the following code as output: class Name(tuple): 'Name(a,)' __slots__ = () _fields = ('a',) def __new__(_cls, a,): 'Create new instance of Name(a,)' return _tuple.__new__(_cls, (a,)) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new Name object from a sequence or iterable' result = new(cls, iterable) if len(result) != 1: raise TypeError('Expected 1 arguments, got %d' % len(result)) return result def __repr__(self): 'Return a nicely formatted representation string' return 'Name(a=%r)' % self def _asdict(self): 'Return a new OrderedDict which maps field names to their values' return OrderedDict(zip(self._fields, self)) def _replace(_self, **kwds): 'Return a new Name object replacing specified fields with new values' result = _self._make(map(kwds.pop, ('a',), _self)) if kwds: raise ValueError('Got unexpected field names: %r' % kwds.keys()) return result def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) __dict__ = _property(_asdict) def __getstate__(self): 'Exclude the OrderedDict from pickling' pass a = _property(_itemgetter(0), doc='Alias for field number 0') ---------- assignee: terry.reedy components: IDLE messages: 312984 nosy: poornaprudhvi, terry.reedy priority: normal severity: normal status: open title: namedtuple displaying the internal code type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32961> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com