Comment #2 on issue 1170 by [email protected]: Error in Collections.Remove
Values From List
http://code.google.com/p/robotframework/issues/detail?id=1170
The funtion in Collections.py is
def remove_values_from_list(self, list_, *values):
"""Removes all occurences of given `values` from `list`.
It is not an error is a value does not exist in the list at all.
Example:
| Remove Values From List | ${L4} | a | c | e | f |
=>
- ${L4} = ['b', 'd']
"""
for value in values:
while value in list_:
list_.remove(value)
With this function if i have a array with ${ips} = [u'10.95.99.149',
u'2a02:45:6:145::24', u'*', u'*'] and I want remove values with "*" , I
should use :
|1| Option1
temp
@{ips}= Create List 12123 123132 * *
Remove Values From List @{ips} *
: FOR ${IP} IN @{ips}
\ Log ${IP}
Return Line 3: four loops, for 10.95.99.149, for 2a02:45:6:145::24 and for
* and for *.
|2| Option2
temp
${ips}= Create List 12123 123132 * *
Remove Values From List ${ips} *
: FOR ${IP} IN ${ips}
\ Log ${IP}
Return Line 4: INFO [u'12123', u'123132']
---
I added at the end of the function remove_values_from_list the line:
return list_
and use:
temp
${ips}= Create List 12123 123132 * *
@{ips}= Remove Values From List ${ips} *
: FOR ${IP} IN @{ips}
\ Log ${IP}
I hope I've managed to explain. Thank.