python - How do I call a function with a list of named arguments? -


Consider the following functions:

  def test (first, second = none, Third =  

I want to be able to call it with a list, which is ready with some arguments (none): First Print Second Print Third Test ('A 'Third =' ​​three ') Print I non-job pseudo code):

  argument = [' one '] argument .append (third =' ​​three ') exam (logic) < / Code> 

how to get it Awareness is?

this

  arguments.append (third = 'three')  

Not possible. Use a dictionary:

  args = {"third": "three"} test ("one", ** args)  

Output: Edit

  one none three :  I do not see any point in using a different structure for positional arguments. Unless there is only one argument,  * ["one"]   is less than "one" . 


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -