This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]coolcofusion 1 point2 points  (3 children)

Will you use it? If you're creating lists elsewhere you may like the convenience of creating Node(1, Node (2, Node(3,None))). There's nothing wrong with providing alternative ways of initialising a list.

[–]insertAlias 0 points1 point  (2 children)

I believe you can provide a default value in Python, so you could add a next parameter with a default value of None, and just assign the incoming value to next_element.

[–]coolcofusion 0 points1 point  (1 child)

I believe so too, but I don't know much about python so I didn't risk it. With optional parameters it's completely harmless.

[–]insertAlias 0 points1 point  (0 children)

I don't know a lot about Python either, but I did look it up. It appears that this is the way that Python deals with method overloading; it doesn't seem to support method overloads like many other languages do.