Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17536

Transform two tuples item by item

From Gnarlodious <gnarlodious@gmail.com>
Newsgroups comp.lang.python
Subject Transform two tuples item by item
Date 2011-12-19 18:04 -0800
Organization http://groups.google.com
Message-ID <21814930.66.1324346655123.JavaMail.geo-discussion-forums@prmw6> (permalink)

Show all headers | View raw


What is the best way to operate on a tuple of values transforming them against a tuple of operations? Result can be a list or tuple:

tup=(35, '34', 0, 1, 31, 0, '&#26082;&#28639;')

from cgi import escape
[tup[0], "<span class='H'>{}</span>".format(tup[1]), bool(tup[2]), bool(tup[3]), tup[4], bool(tup[5]), escape(tup[6])]

-> [35, "<span class='H'>34</span>", False, True, 31, False, '&amp;#26082;&amp;#28639;']

But I want to loop rather than subscripting.

-- Gnarlie

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Transform two tuples item by item Gnarlodious <gnarlodious@gmail.com> - 2011-12-19 18:04 -0800
  Re: Transform two tuples item by item Tim Chase <python.list@tim.thechases.com> - 2011-12-19 20:42 -0600
  Re: Transform two tuples item by item Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-20 03:40 +0000
  Re: Transform two tuples item by item Gnarlodious <gnarlodious@gmail.com> - 2011-12-19 19:40 -0800

csiph-web