Is there any non-explicit for
way to call a member n
times upon an object?
I was thinking about some map/reduce/lambda
approach, but I couldn't figure out a way to do this -- if it's possible.
Just to add context, I'm using BeautifulSoup
, and I'm extracting some elements from an html table; I extract some elements, and then, the last one.
Since I have:
# First value
print value.text
# Second value
value = value.nextSibling
print value.text
# Ninth value
for i in xrange(1, 7):
value = value.nextSibling
print value.text
I was wondering if there's any lambda
approach -- or something else -- that would allow me to do this:
# Ninth value
((value = value.nextSibling) for i in xrange(1, 7))
print value.text
P.S.: No, there's no problem whatsoever with the for
approach, except I really enjoy one-liner solutions, and this would fit really nice in my code.