Creating function object from text

Michel Claveau/Hamster No.Spam.mc at No.Spam.mclaveau.No.Spam.com
Sun Apr 18 14:13:10 EDT 2004


Bonjour !

Ce code fonctionne, chez moi :

    src='''def toto(i):
        return i*2'''

    exec src
    print toto(3)   # => 6



Mais, dans certains cas, je suis obligé d'ajouter :
    global toto



Bonne soirée !

--
Michel Claveau





More information about the Python-list mailing list