{"action":"created","issue":{"url":"https://api.github.com/repos/robotframework/robotframework/issues/1561","labels_url":"https://api.github.com/repos/robotframework/robotframework/issues/1561/labels{/name}","comments_url":"https://api.github.com/repos/robotframework/robotframework/issues/1561/comments","events_url":"https://api.github.com/repos/robotframework/robotframework/issues/1561/events","html_url":"https://github.com/robotframework/robotframework/issues/1561","id":36761744,"number":1561,"title":"Support Python style `**kwargs` with user keywords","user":{"login":"spooning","id":1658993,"avatar_url":"https://avatars.githubusercontent.com/u/1658993?v=3","gravatar_id":"","url":"https://api.github.com/users/spooning","html_url":"https://github.com/spooning","followers_url":"https://api.github.com/users/spooning/followers","following_url":"https://api.github.com/users/spooning/following{/other_user}","gists_url":"https://api.github.com/users/spooning/gists{/gist_id}","starred_url":"https://api.github.com/users/spooning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spooning/subscriptions","organizations_url":"https://api.github.com/users/spooning/orgs","repos_url":"https://api.github.com/users/spooning/repos","events_url":"https://api.github.com/users/spooning/events{/privacy}","received_events_url":"https://api.github.com/users/spooning/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/robotframework/robotframework/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/robotframework/robotframework/labels/prio-critical","name":"prio-critical","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"pekkaklarck","id":114985,"avatar_url":"https://avatars.githubusercontent.com/u/114985?v=3","gravatar_id":"","url":"https://api.github.com/users/pekkaklarck","html_url":"https://github.com/pekkaklarck","followers_url":"https://api.github.com/users/pekkaklarck/followers","following_url":"https://api.github.com/users/pekkaklarck/following{/other_user}","gists_url":"https://api.github.com/users/pekkaklarck/gists{/gist_id}","starred_url":"https://api.github.com/users/pekkaklarck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pekkaklarck/subscriptions","organizations_url":"https://api.github.com/users/pekkaklarck/orgs","repos_url":"https://api.github.com/users/pekkaklarck/repos","events_url":"https://api.github.com/users/pekkaklarck/events{/privacy}","received_events_url":"https://api.github.com/users/pekkaklarck/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/robotframework/robotframework/milestones/16","labels_url":"https://api.github.com/repos/robotframework/robotframework/milestones/16/labels","id":705012,"number":16,"title":"2.9","description":null,"creator":{"login":"spooning","id":1658993,"avatar_url":"https://avatars.githubusercontent.com/u/1658993?v=3","gravatar_id":"","url":"https://api.github.com/users/spooning","html_url":"https://github.com/spooning","followers_url":"https://api.github.com/users/spooning/followers","following_url":"https://api.github.com/users/spooning/following{/other_user}","gists_url":"https://api.github.com/users/spooning/gists{/gist_id}","starred_url":"https://api.github.com/users/spooning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spooning/subscriptions","organizations_url":"https://api.github.com/users/spooning/orgs","repos_url":"https://api.github.com/users/spooning/repos","events_url":"https://api.github.com/users/spooning/events{/privacy}","received_events_url":"https://api.github.com/users/spooning/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":3,"state":"open","created_at":"2014-06-29T21:43:00Z","updated_at":"2015-02-06T07:30:13Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2014-06-30T00:11:49Z","updated_at":"2015-02-08T23:03:04Z","closed_at":null,"body":"> *Originally submitted to [Google Code](http://code.google.com/p/robotframework/issues/detail?id=1561) by @pekkaklarck on 1 Nov 2013*\r\n\r\n\r\nPython keywords have supported kwargs since RF 2.8 (<a class=\"closed_ref\" href=\"https://code.google.com/p/robotframework/issues/detail?id=1383\" title=\"Python's keyword argument syntax is supported\"> issue 1383 </a>) and dynamic libraries ought to get the support in RF 2.8.2 (<a class=\"closed_ref\" href=\"https://code.google.com/p/robotframework/issues/detail?id=1500\" title=\"**kwargs support for dynamic test libraries\"> issue 1500 </a>). Full powers of this handy new functionality cannot be used yet, though, because user keywords cannot take kwargs. This limitation is illustrated by the examples below.\r\n\r\nFirst, let's assume we a keyword like below for running a some program:\r\n\r\n    *** Keywords ***\r\n    Run My Program\r\n        [Arguments]    @{args}\r\n        Run Process    myprog    @{args}    stdout=/tmp/stdout.txt\r\n\r\nThe above keyword uses `Process.Run Process` keyword, which takes optional configuration parameters as kwargs. Using the keyword is simple:\r\n\r\n    Run My Program                    # no argument\r\n    Run My Program    arg1    arg2    # two arguments\r\n    \r\nThe problem is that we cannot change the keyword to take optional configuration. The best we can do is this:\r\n\r\n    *** Keywords ***\r\n    Run My Program\r\n        [Arguments]    ${stdout}=/tmp/stdout.txt    @{args}\r\n        Run Process    myprog    @{args}    stdout=${stdout}\r\n\r\nUnfortunately, running it like earlier won't work anymore:\r\n\r\n    Run My Program                    # this still works\r\n    Run My Program    arg1    arg2    # ooops, ${stdout} got value arg1!!\r\n    Run My Program    out.txt    arg  # works but is hard to understand\r\n\r\nA solution to this problem is enhancing user keywords so that they can take free kwargs just like Python (and soon dynamic) keywords can. In practice the keyword could look something like this:\r\n\r\n    *** Keywords ***\r\n    Run My Program\r\n        [Arguments]    @{args}    &{config}\r\n        Run Process    myprog    @{args}    &{config}\r\n\r\nand could be used like\r\n\r\n    Run My Program    arg1    arg2             # same as original\r\n    Run My Program    arg    stdout=out.txt    # works and is clear\r\n\r\nAs the above example shows, a key to resolving this issue is having a new variable type that gets free keyword arguments and can be used to pass them further. It will naturally be a dictionary, and can be also used for other purposes (<a href=\"https://code.google.com/p/robotframework/issues/detail?id=1450\" title=\"Dictionary variable type\">issue 1450</a>). Will the new variable use &amp;{name} syntax or something else is still open.\r\n\r\nChanges needed to implement this issue are so large that it can only be done in a major release.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/robotframework/robotframework/issues/comments/73438053","html_url":"https://github.com/robotframework/robotframework/issues/1561#issuecomment-73438053","issue_url":"https://api.github.com/repos/robotframework/robotframework/issues/1561","id":73438053,"user":{"login":"pekkaklarck","id":114985,"avatar_url":"https://avatars.githubusercontent.com/u/114985?v=3","gravatar_id":"","url":"https://api.github.com/users/pekkaklarck","html_url":"https://github.com/pekkaklarck","followers_url":"https://api.github.com/users/pekkaklarck/followers","following_url":"https://api.github.com/users/pekkaklarck/following{/other_user}","gists_url":"https://api.github.com/users/pekkaklarck/gists{/gist_id}","starred_url":"https://api.github.com/users/pekkaklarck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pekkaklarck/subscriptions","organizations_url":"https://api.github.com/users/pekkaklarck/orgs","repos_url":"https://api.github.com/users/pekkaklarck/repos","events_url":"https://api.github.com/users/pekkaklarck/events{/privacy}","received_events_url":"https://api.github.com/users/pekkaklarck/received_events","type":"User","site_admin":false},"created_at":"2015-02-08T23:03:04Z","updated_at":"2015-02-08T23:03:04Z","body":"Trace logging &{kwargs} was implemented by 681c65e655913bd3b9fe513595be3ff9aa1cc17f. This issue now waits for `dict-variable` branch to be merged to master and documentation in User Guide."}}