On 9/22/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:

"fumanchu" <[EMAIL PROTECTED]> writes:

> def quadratic(**kwds):
>     a = kwds.get('a', 1)
>     b = kwds.get('b', 2)
>     c = kwds.get ('c', 3)
>     a, b, c = map(int, (a, b, c))
>     root = math.sqrt((b ** 2) - (4 * a * c))
>     return ((-b + root)/2a), ((-b - root)/2a))

You can always make this look like:

def quadratic(**kwds):
     a, b, c = map(int, (kwds.get('a', 1),
                         kwds.get('b', 2),
                         kwds.get('c', 3)))
     root = math.sqrt((b ** 2) - (4 * a * c))
     return ((-b + root)/2a), ((-b - root)/2a))

(If you were using validators that "map" wouldn't be needed, making your code
even clearer ;-))


Can you provide an example of using validators here?

Kevin H

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to