<s> from keyword import iskeyword as _iskeyword <EOL> from operator import itemgetter as _itemgetter <EOL> import sys as _sys <EOL> def namedtuple ( typename , field_names ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( field_names , basestring ) : <EOL> field_names = field_names . replace ( '<STR_LIT:U+002C>' , '<STR_LIT:U+0020>' ) . split ( ) <EOL> field_names = tuple ( map ( str , field_names ) ) <EOL> for name in ( typename , ) + field_names : <EOL> if not all ( c . isalnum ( ) or c == '<STR_LIT:_>' for c in name ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if _iskeyword ( name ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if name [ <NUM_LIT:0> ] . isdigit ( ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> seen_names = set ( ) <EOL> for name in field_names : <EOL> if name . startswith ( '<STR_LIT:_>' ) : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> if name in seen_names : <EOL> raise ValueError ( '<STR_LIT>' % name ) <EOL> seen_names . add ( name ) <EOL> numfields = len ( field_names ) <EOL> argtxt = repr ( field_names ) . replace ( "<STR_LIT:'>" , "<STR_LIT>" ) [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> reprtxt = '<STR_LIT:U+002CU+0020>' . join ( '<STR_LIT>' % name for name in field_names ) <EOL> dicttxt = '<STR_LIT:U+002CU+0020>' . join ( '<STR_LIT>' % ( name , pos ) for pos , name in enumerate ( field_names ) ) <EOL> template = '''<STR_LIT>''' % locals ( ) <EOL> for i , name in enumerate ( field_names ) : <EOL> template += '<STR_LIT>' % ( name , i ) <EOL> namespace = dict ( _itemgetter = _itemgetter , __name__ = '<STR_LIT>' % typename , <EOL> _property = property , _tuple = tuple ) <EOL> try : <EOL> exec ( template , namespace ) <EOL> except SyntaxError : <EOL> e = _sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> raise SyntaxError ( e . message + '<STR_LIT>' + template ) <EOL> result = namespace [ typename ] <EOL> if hasattr ( _sys , '<STR_LIT>' ) : <EOL> result . __module__ = _sys . _getframe ( <NUM_LIT:1> ) . f_globals . get ( '<STR_LIT>' , '<STR_LIT:__main__>' ) <EOL> return result </s>
