Reputation: 151
How can we return more than one value using Python-Ladon functions?
Upvotes: 0
Views: 326
Reputation: 16403
You can return more values by wrapping them into a list inside a class that you use as the returntype in the decorator ladonize
.
Based on an example in the documentation for ladon:
from ladon.ladonizer import ladonize
from ladon.types.ladontype import LadonType
class Response(LadonType):
values = [int]
class MyService(object):
@ladonize(int, int, rtype=Response)
def foo(self, a, b):
result = Response()
result.values = [a+b, a*b]
return result
Upvotes: 1