How to dynamic insert more conditional statements into a function

Shane shengcer at gmail.com
Tue Mar 9 16:48:42 EST 2010


Hi I am a newbie for Python

Here is a question, say I have a list L,

function foo is:

def foo(L):
    if L[0] > 0: return True

if later I want another function goo which returns "True" when L[0]
and L[1] are both > 0, i.e.,

def goo(L):
    if L[0] > 0 and L[1] > 0: return True

Can anybody tell me how can I write the function "goo" based upon the
function "foo"? Thanks!
I know if it is implementable, I should use "decorator". But I just
cannot figure out how.



More information about the Python-list mailing list