471,052 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,052 software developers and data experts.

Shed my a light :)

Hi,
I using eval for quite strange reason, as long as I don't know a different
way to implement.

An example:

actions= ('print', 'sum', 'divide', 'myfunction')
parameters=(5, 'nothing',5.63, object)

for routines in actions:
routines(parameters)

I'd like to note that actions are string or string expressions of the program
functions or python itself, so I've in my program something like:

for nn in actions:
eval('cp.%s' %nn)

Where cp is an instance.

So I'm asking here whether exist a way that these string become functions
inside my program, without using eval()

--
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
Jun 2 '08 #1
0 920

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mark Dufour | last post: by
reply views Thread by Mark Dufour | last post: by
1 post views Thread by Mark Dufour | last post: by
reply views Thread by Mark Dufour | last post: by
31 posts views Thread by Mark Dufour | last post: by
reply views Thread by Mark Dufour | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.