Question about None
tjreedy at udel.edu
Sat Jun 13 18:27:45 CEST 2009
Steven D'Aprano wrote:
[ snip excellent discussion of proper use of assert]
> The third bug (the nitpick) is a bug in the API: you name the argument "nxt"
> with no e, but in the error message, you call it "next" with an e. The fact
> that any intelligent person should be able to guess what parameter the
> error is referring to doesn't make it less wrong.
> So, fixing the three issues:
> def setNext(next):
> if not (next is None or isinstance(next, Node)):
> raise ValueError("next must be a Node")
> self.next = next
[counternit] Of course, next() is a builtin function and some consider
reusing builtin names as bare names (versus attribute names) a bad
habit. I think the OP had a good idea in using a variation, but should
have been consistent.
More information about the Python-list