Xan, it&#39;s &quot;not defined&quot; because you haven&#39;t defined a function called &quot;function&quot; or any variable called &quot;function&quot;.<div><div><br></div><div><div>Nom: descripci, Tipus: &lt;type &#39;str&#39;&gt;, Valor: primera tasca</div>

<div>Nom: unmes, Tipus: &lt;type &#39;str&#39;&gt;, Valor: &lt;function &lt;lambda&gt; at 0x10df736e0&gt;</div><div><div><div><br></div><div>str comes back as &lt;type &#39;str&#39;&gt; because str is a built-in method and python and will always be in the namespace.</div>

<div><br></div><div>See <a href="http://docs.python.org/library/functions.html#str">http://docs.python.org/library/functions.html#str</a><br><br><div class="gmail_quote">On Mon, May 7, 2012 at 1:24 PM, xancorreu <span dir="ltr">&lt;<a href="mailto:xancorreu@gmail.com" target="_blank">xancorreu@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I have this script:<br>
<br>
from types import *<br>
<br>
class Tag:<br>
<br>
    def __init__(self, nom, tipus, valor):<br>
        self.nom = nom<br>
        self.tipus = tipus<br>
        self.valor = valor<br>
<br>
    def __str__(self):<br>
        return &quot;Nom: &quot; + str(self.nom) + &quot;, Tipus: &quot; + str(self.tipus)  + &quot;, Valor: &quot; + str(self.valor)<br>
<br>
<br>
def main():<br>
    a = Tag(&quot;descripció&quot;, str, &quot;primera tasca&quot;)<br>
    b = Tag(&quot;unmes&quot;, str, lambda x: x+1)<br>
    print(a)<br>
    print(b)<br>
<br>
if __name__ == &#39;__main__&#39;:<br>
        main()<br>
<br>
<br>
All is ok, but when I substitute b = Tag(&quot;unmes&quot;, str, lambda x: x+1) for b = Tag(&quot;unmes&quot;, 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)<br>



<br>
I use python3<br>
<br>
<br>
Thanks in advance,<br>
Xan.<br>
______________________________<u></u>_________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</blockquote></div><br></div>
</div></div></div></div>