This question already has an answer here:
Often when coding I'll get stuck on a particularly tricky problem and will go about searching for a solution. More often than not this leads me to a StackOverflow question that provides a full or partial solution, often with code than can be used directly by pasting into the original code.
In some cases this can lead to code that looks unintuitive or does some seemingly unusual things - such as overloading existing methods in classes, reimplementing in-built functions with the same name or otherwise breaking some aspect of "good practise" to achieve a solution. Sometimes these look like bad practise, but due to problems in the code
In cases like these I often find myself including a link to the answer that I've implemented, with some brief explanation rather than rewriting or duplicating verbose explanations.
Is including URLs to solutions for these kinds of problems in comments a common practise, or is there a better way to document this kind of code?
As an example of this kind of issue, I recently asked a question about resolving a conflict with the Python property decorator, where the solution was to rename the Python in-built function and included a link to the question in the code.