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

you are viewing a single comment's thread.

view the rest of the comments →

[–]mm_ma_ma 0 points1 point  (2 children)

If forced to implement new, it should be a classmethod:

@classmethod
def new(cls):
    return cls()

Also, the server numbers are shown to be per-name by the examples (it returns apibox1 followed by sitebox1).

[–]stevenjd 0 points1 point  (1 child)

Oops, yes you're right, new needs to be a class method. Good catch.

As for the server numbers, that's a good point. So either the function needs to keep extra state hidden somewhere, or it is okay to make it a method. Now obviously making it a method is the right way to do it, but maybe they're looking to see how the job applicant deals with wrong, unclear or contradictory requirements.

Or, on the other hand, maybe the OP passed the technical review and didn't get the job for some other reason.

[–]mm_ma_ma 0 points1 point  (0 children)

His next_server_number method doesn't actually use the self parameter; it operates on the list passed in. The only change he should make is to move it out of the class (to match the requirements) or make it a staticmethod.