Wednesday, 14 August 2013

Propagate latest not None value to rest of items in izip_longest

Propagate latest not None value to rest of items in izip_longest

I'm wondering if there is a way to have the default values of an
"unmatched" item in a list set to the latest value in izip_longtest
function.
The problem: i have a word which have a position on x, on y, and a
rotation. Theses ones can be multiple and each letter of the word must
have position/rotation.
More explicitely: i have two lists:
the first one is itself a tuple (x, y, r) which are the positions and
rotation that will match letters.
the second is the character that will match the positions/rotation.
By example, if i have the word "HELLO" and x = [1,2,3,4,5], y =
[6,7,8,9,10] and r = [11,12,13,14,15].
The 'H' letter will have x = 1, y = 6, y = 11 The last letter 'O' will
have x = 5, y = 10, r = 15
But, if the word is "PROBLEM" and x = [1], only the 'P' letter will match
an x value and all the other letters will be set to None with
izip_longest.
What i want is to "progagate" the latest or only one x to all the other
letters. So, please, If you have any suggestion or solution, tell me.
Thanks by advance !

No comments:

Post a Comment