user1059150
user1059150

Reputation: 151

How can we return instance of class from ladon functions in python?

I want to return a instance of user defined class and list of instances of user defined class from a ladon function? Is it possible?

Upvotes: 0

Views: 130

Answers (1)

NullPoiиteя
NullPoiиteя

Reputation: 57322

this might help you its something like this

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: 0

Related Questions