How to expand lists with one item in RETURN statement

31 views
Skip to first unread message

Andreas Kemmler

unread,
Jan 17, 2023, 7:34:06 AM1/17/23
to robotframework-users
The @ operator expands lists, but sometimes not? Example for Robot Framework 6.0.1 (Python 3.8.0 on win32):

*** test cases ***
tryme
  ${first}  get stuff  1
  log to console  one: ${first}
       
  ${first}  ${second}  get stuff  2
  log to console  two: ${first} ${second}

*** keywords ***
get stuff
      [Arguments]  ${count}
      ${stuff}  create list  foo  bar
      ${ret}  get slice from list  ${stuff}  0  ${count}
      RETURN  @{ret}

Output:
one: ['foo']
two: foo bar

Hmm, why do I get a list in first case?
How can I force list expansion in that case without branching?

Andreas Kemmler

unread,
Jan 17, 2023, 8:03:49 AM1/17/23
to robotframework-users
Maybe "expand" is the wrong word here. What I mean is rather "unpack".
Reply all
Reply to author
Forward
0 new messages