Xan, it's "not defined" because you haven't defined a function called "function" or any variable called "function".
Nom: descripci, Tipus: <type 'str'>, Valor: primera tasca Nom: unmes, Tipus: <type 'str'>, Valor: <function <lambda> at 0x10df736e0> str comes back as <type 'str'> because str is a built-in method and python and will always be in the namespace. See http://docs.python.org/library/functions.html#str On Mon, May 7, 2012 at 1:24 PM, xancorreu <xancor...@gmail.com> wrote: > Hi, > > I have this script: > > from types import * > > class Tag: > > def __init__(self, nom, tipus, valor): > self.nom = nom > self.tipus = tipus > self.valor = valor > > def __str__(self): > return "Nom: " + str(self.nom) + ", Tipus: " + str(self.tipus) + > ", Valor: " + str(self.valor) > > > def main(): > a = Tag("descripció", str, "primera tasca") > b = Tag("unmes", str, lambda x: x+1) > print(a) > print(b) > > if __name__ == '__main__': > main() > > > All is ok, but when I substitute b = Tag("unmes", str, lambda x: x+1) for > b = Tag("unmes", function, lambda x: x+1) I receive an error that function > is not globally defined variable. How can I say that function is the > types.function? (the type of lambda x: x+1) > > I use python3 > > > Thanks in advance, > Xan. > ______________________________**_________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor