Can a class method have more than one argument named self?

Question

Can a class method have more than one argument named self?

Answer

NO, having multiple arguments to a function with the same name will generate a SyntaxError: duplicate argument error in Python. This is true regardless of whether it is a standalone function or part of a class.

7 Likes

self by definition denotes a singularity. Can we be more than ourself?

Every instance is a self when it becomes the context of a method. That is because instances are like the return value of a function factory.

Look at this carefully. Does a new instance not inherit methods? Is it not instantiated with unique instance variable values? That is what a function factory does. Except instead of instantiating objects it instantiates functions.

The thing in common with both is unique data given to their instance variables that can only be accessed on that instance. It is all scope related.

14 Likes

You could say that in programming you have to be very “self” conscious.
I’m sorry. I couldn’t resist.

44 Likes

3 posts were split to a new topic: Right code but showing error