user1059150
user1059150

Reputation: 151

Return more than one value using Python - Ladon functions

How can we return more than one value using Python-Ladon functions?

Upvotes: 0

Views: 326

Answers (1)

halex
halex

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

Related Questions