Re: FLexible formatted text involving nested lists?

2008-10-10 Thread davidsands
On Oct 10, 4:36 am, RossRGK [EMAIL PROTECTED] wrote: I'm having trouble getting my head around a solution for a situation where I need to flexibly format some text with a varying number of embedded fields. Here's a simplified description of my challenge... I have a list of lists called

Re: FLexible formatted text involving nested lists?

2008-10-10 Thread RossRGK
Kerri Reno wrote: Ross, I'm no expert in python, so excuse me if this is inane. What I would do is have fmts be a dictionary where fmts = { 3 = 'oats %0d kilos over %0d days with %0d workers', 2 = 'barley %0d lbs for %0d hours', 1 = 'apples %0d baskets'} then something like

Re: FLexible formatted text involving nested lists?

2008-10-10 Thread RossRGK
davidsands wrote: The tuple() type-conversion function will do what you need: print fmts[0] % tuple(bigList[0]) print fmts[1] % tuple(bigList[1]) print fmts[2] % tuple(bigList[2]) I never thought of the tuple type conversion - that looks promising. Thanks for that! R. --

Re: FLexible formatted text involving nested lists?

2008-10-10 Thread Tino Wildenhain
Hi, RossRGK wrote: Kerri Reno wrote: Ross, I'm no expert in python, so excuse me if this is inane. What I would do is have fmts be a dictionary where fmts = { 3 = 'oats %0d kilos over %0d days with %0d workers', 2 = 'barley %0d lbs for %0d hours', 1 = 'apples %0d baskets'}

FLexible formatted text involving nested lists?

2008-10-09 Thread RossRGK
I'm having trouble getting my head around a solution for a situation where I need to flexibly format some text with a varying number of embedded fields. Here's a simplified description of my challenge... I have a list of lists called bigList: bigList = [ little, small, tiny] The sub-lists

Re: FLexible formatted text involving nested lists?

2008-10-09 Thread Kerri Reno
Ross, I'm no expert in python, so excuse me if this is inane. What I would do is have fmts be a dictionary where fmts = { 3 = 'oats %0d kilos over %0d days with %0d workers', 2 = 'barley %0d lbs for %0d hours', 1 = 'apples %0d baskets'} then something like for x in bigList: