>     @defer.inlineCallbacks
>     def round_val(id, value, rule):
>         """
>         Return first element of round_value_and_percent
>         """
>         defer.returnValue(round_value_and_percent(id, value, 0, rule)[0])

> When I do:
> result = yield round_val(1, 2, 3)
>
> I get this: Deferred instance has no attribute '__getitem__'
>

round_value_and_percent returns a Deferred. You probably want:

     @defer.inlineCallbacks
     def round_val(id, value, rule):
         """
         Return first element of round_value_and_percent
         """
        x = yield round_value_and_percent(id, value, 0, rule)
         defer.returnValue(x[0])

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to