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

Reply via email to