On Mon, 22 Oct 2007 23:16:38 +, Steven D'Aprano wrote:
>> how could I call a_string as function?
>
> Others have suggested eval() and exec. Both will work, but have MAJOR
> security implications.
Oh, and they are seriously slower too.
>>> import timeit
>>> timeit.Timer('f("2.3")',
... 'f =
On Mon, 22 Oct 2007 08:54:02 +, james_027 wrote:
> hi,
>
> i have a function that I could like to call, but to make it more dynamic
> I am constructing a string first that could equivalent to the name of
> the function I wish to call.
That is not the right solution to dynamic functions. The
>>> exec("import datetime") ; exec("x = datetime." + "date." + "today()")
>>> print x
2007-10-22
james_027 wrote:
> hi,
>
> i have a function that I could like to call, but to make it more
> dynamic I am constructing a string first that could equivalent to the
> name of the function I wish to c
Jarek Zgoda a écrit :
> Trent Nelson napisał(a):
>>> i have a function that I could like to call, but to make it more
>>> dynamic I am constructing a string first that could equivalent to the
>>> name of the function I wish to call. how could I do that? the string
>>> could might include name of th
james_027 a écrit :
> hi,
>
> i have a function that I could like to call, but to make it more
> dynamic I am constructing a string first that could equivalent to the
> name of the function I wish to call. how could I do that? the string
> could might include name of the module.
>
> for example
>
On Oct 22, 5:46 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Do not use eval(). Not only it's deprecated, it's also unsafe.
I don't think it's deprecated; it doesn't say so:
http://docs.python.org/lib/built-in-funcs.html#l2h-25
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 22, 4:41 am, "Francesco Guerrieri" <[EMAIL PROTECTED]>
wrote:
> On 10/22/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> > hi,
>
> > i have a function that I could like to call, but to make it more
> > dynamic I am constructing a string first that could equivalent to the
> > name of the functio
Trent Nelson napisał(a):
>> i have a function that I could like to call, but to make it more
>> dynamic I am constructing a string first that could equivalent to the
>> name of the function I wish to call. how could I do that? the string
>> could might include name of the module.
>>
>> for example
> i have a function that I could like to call, but to make it more
> dynamic I am constructing a string first that could equivalent to the
> name of the function I wish to call. how could I do that? the string
> could might include name of the module.
>
> for example
>
> a_string = 'datetime.' +
On 10/22/07, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> i have a function that I could like to call, but to make it more
> dynamic I am constructing a string first that could equivalent to the
> name of the function I wish to call. how could I do that? the string
> could might include name of t
hi,
i have a function that I could like to call, but to make it more
dynamic I am constructing a string first that could equivalent to the
name of the function I wish to call. how could I do that? the string
could might include name of the module.
for example
a_string = 'datetime.' + 'today()'
11 matches
Mail list logo