Borked links

Fragment of a discussion from User talk:Nx
Jump to navigation Jump to search

Surely there is some way to obtain the errorlevel in Python without having to catch an exception?

Mjollnir.svgListenerXTalkerX07:25, 27 December 2011

Probably, but would it be faster or simpler?

Blue (pester)08:06, 27 December 2011

Simpler, certainly. Faster, I understand that unnecessary use of exceptions in C++ is inefficient, though I am unsure whether that applies to Python.

Mjollnir.svgListenerXTalkerX08:16, 27 December 2011

As Nx is our resident techie and this is his talk page, I'll defer to him on this. I'm not extensively knowledgeable about Python anyway.

Blue (pester)08:25, 27 December 2011

Wait, aren't you using Pywikipediabot's weblinkchecker.py? Where is that code snippet from?

-- Nx / talk09:55, 27 December 2011

Oh, that exists. Well I kind of reinvented the wheel a bit.

Blue (pester)16:26, 27 December 2011
 
 
 
 

What's wrong with using an exception?

Python uses exceptions for error handling, and I think it's a more elegant way than having to check the return value against some arbitrary value that's defined as error and may be -1, 0, Null etc. depending on what the function is.

-- Nx / talk09:27, 27 December 2011

I meant that Blue should try to find some function in Python that just returned 404 or whatever if the link was broken, without raising an exception.

Mjollnir.svgListenerXTalkerX09:44, 27 December 2011