Is there any implicit way to forcall member ntimes for an object?
I was thinking of some kind of approach map/reduce/lambda, but I could not figure out how to do it - if possible.
Just to add context, I use BeautifulSoupand I extract some elements from the 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 was any approach lambda- or something else - that would allow me to do this:
# Ninth value
((value = value.nextSibling) for i in xrange(1, 7))
print value.text
PS: No, there is no problem with the approach for, except that I really like single-line solutions, and it will be very convenient in my code.
source
share