I have to say that I first thought of a more complex problem. But the answer of David Wolever is absolutely right. This is just a duplicate of me here, which creates a problem. Thus, the positional parameters go beyond the line, and asType receives the value as an assignment parameter (once) and as a keyword parameter (second time!).
A more interesting problem is what to do when you want to improve the called procedure (createTable in the example) without increasing the intermediate function. Here's the solution ** args does the trick:
For instance:
def createOrOpenTable(self, tableName, schema, **args): if self.tableExists(tableName): return self.openTable(tableName, **args) else: return self.createTable(tableName, schema, **args)
This way you can improve the signature of createTable and openTable without changing createOrOpenTable.
When create and openTable can have different keyword parameters, then, of course, both procedures should be defined as follows:
def createTable(self, tableName, schema, asType=None, **others): ...
The others parameter absorbs all the parameters of the keyword that are unknown to the method - it also does not need to be evaluated.
source share