0

Related to, but substantially different from, the problem posed here. I applied the try/except solution posed there in a script for pulling summaries. Code here:

termlist = ['carcass','richard nixon','polar bear']
for term in termlist:
    try:
        p =wikipedia.summary(wse(term)[0])
    except wikipedia.DisambiguationError as e:
        p = wikipedia.summary(e.options)[0]
    print(p)

The problem is that the except branch returns another disambiguation error. What can I do here outside of nesting/ recursion?

2
  • Just write another try-except block inside except wikipedia.DisambiguationError as e:.
    – Ajay Dabas
    Jan 19, 2020 at 5:53
  • That didn't help (pulled another). Jan 19, 2020 at 23:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.