Parsing a large number of parms to a print statement.

2009-10-22 Thread KB
Hi,

I have to pass over 150 parameters to a print statement ala:

print %s text %s other text %s 150'th unique text %s % (v
[0], v[1], ... v[150])

I can't use a for loop like I normally would over the list v due to
the different text fragments between each var.

Is there a lambda function I can use in place of '% (v[0],v[1]...v
[150])' ???

Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Ethan Furman

KB wrote:

Hi,

I have to pass over 150 parameters to a print statement ala:

print %s text %s other text %s 150'th unique text %s % (v
[0], v[1], ... v[150])

I can't use a for loop like I normally would over the list v due to
the different text fragments between each var.

Is there a lambda function I can use in place of '% (v[0],v[1]...v
[150])' ???

Thanks in advance.


Actually, you are only sending one parameter to print.

Is v iterable?  _And_ does v have 150 values?  _And_ can you say 
tuple(v) and get (v[0], v[1], v[2], ..., v[149])?  If so, try:


print %s blah %s blah blah %s   % tuple(v)

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread MRAB

KB wrote:

Hi,

I have to pass over 150 parameters to a print statement ala:

print %s text %s other text %s 150'th unique text %s % (v
[0], v[1], ... v[150])

I can't use a for loop like I normally would over the list v due to
the different text fragments between each var.

Is there a lambda function I can use in place of '% (v[0],v[1]...v
[150])' ???


print %s text %s other text %s 150'th unique text %s % tuple(v)

If v is already a tuple then that's not necessary! :-)

--
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Benjamin Kaplan
On Thu, Oct 22, 2009 at 5:16 PM, KB ke...@nekotaku.com wrote:
 Hi,

 I have to pass over 150 parameters to a print statement ala:

 print %s text %s other text %s 150'th unique text %s % (v
 [0], v[1], ... v[150])

 I can't use a for loop like I normally would over the list v due to
 the different text fragments between each var.

 Is there a lambda function I can use in place of '% (v[0],v[1]...v
 [150])' ???

 Thanks in advance.

Why use a lambda?

long string with lots of params % tuple(v)



 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Paul Rubin
KB ke...@nekotaku.com writes:
 I have to pass over 150 parameters to a print statement ala:
 
 print %s text %s other text %s 150'th unique text %s % (v
 [0], v[1], ... v[150])
 
 I can't use a for loop like I normally would over the list v due to
 the different text fragments between each var.

print %s text ... % tuple(v[:150])

But what you're trying to do looks bizarre.  Find a way to make the
constant strings inside the print statement part of the data.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Andre Engels
On Thu, Oct 22, 2009 at 11:16 PM, KB ke...@nekotaku.com wrote:
 Hi,

 I have to pass over 150 parameters to a print statement ala:

 print %s text %s other text %s 150'th unique text %s % (v
 [0], v[1], ... v[150])

 I can't use a for loop like I normally would over the list v due to
 the different text fragments between each var.

 Is there a lambda function I can use in place of '% (v[0],v[1]...v
 [150])' ???

It's not a lambda function, but what about

print %s text %s other text %s 150'th unique text %s % tuple(v)




-- 
André Engels, andreeng...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread KB
Excuse the top-post, but thanks to all, the tuple was the way to go.

On Oct 22, 2:16 pm, KB ke...@nekotaku.com wrote:
 Hi,

 I have to pass over 150 parameters to a print statement ala:

 print %s text %s other text %s 150'th unique text %s % (v
 [0], v[1], ... v[150])

 I can't use a for loop like I normally would over the list v due to
 the different text fragments between each var.

 Is there a lambda function I can use in place of '% (v[0],v[1]...v
 [150])' ???

 Thanks in advance.

-- 
http://mail.python.org/mailman/listinfo/python-list