Movatterモバイル変換
[0]ホーム
Call a function using a variable
Sean 'Shaleh' Perryshaleh at valinux.com
Fri Apr 27 16:34:40 EDT 2001
On 27-Apr-2001 Bjorn Pettersen wrote:>> From: Colin Meeks [mailto:colinmeeks at home.com]>>>> Does anybody know if it's possible to do something along the>> following lines>> :>>>> myfunction="test">> x=myfunction>>>> Basically what I want is when the x variable gets declared it>> get's it's>> data from the function test()>> myfunction = eval('test')> x = myfunction()>> of course, if you're not sure what you're passing to eval you might get> surprising results <wink>>my question is why use a string? You can just use the function itself:myfunc = existing_funcx = myfunc()
More information about the Python-listmailing list
[8]ページ先頭