hello, Here's the code I have: The weird thing is when I do something like: eval ch.level=50 it seems to not work, but I can get ch.level def cmd_eval(ch, cmd, arg): if not len(arg): ch.send("Eval what, exactly?") return ch.send("=>"+str( eval(arg,globals(),locals()))) ideas would be great. thanks, Thanks, Tyler Littlefield Web: tysdomain.com email: tyler@xxxxxxxxxxxxx My programs don't have bugs, they're called randomly added features.----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx> Sent: Tuesday, March 24, 2009 9:08 AM Subject: [program-l] Re: quick python question
You can use the eval function to evaluate an expression, or in your example, the exec statement to execute a statement (Python draws a distinction between an expression and a statement). Note that use of such techniques can risk security if there is a way for arbitrary code to be injected from an external source. Jamal On Mon, 23 Mar 2009, Tyler Littlefield wrote:Date: Mon, 23 Mar 2009 21:57:49 -0600 From: Tyler Littlefield <tyler@xxxxxxxxxxxxx> Reply-To: program-l@xxxxxxxxxxxxx To: program-l@xxxxxxxxxxxxx Subject: [program-l] quick python question Hello list,I'm working on a mud that uses python as it's scripting language, and had a quick question.Is it possible to evaluate python code? Like, from within the mud I'd like to do something like: eval (find_char("azar")).level=100 and have azar's level be set to 100. Thanks, Tyler Littlefield Web: tysdomain.com email: tyler@xxxxxxxxxxxxx My programs don't have bugs, they're called randomly added features.** To leave the list, click on the immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe] ** If this link doesn't work then send a message to: ** program-l-request@xxxxxxxxxxxxx ** and in the Subject line type ** unsubscribe ** For other list commands such as vacation mode, click on the ** immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq] ** or send a message, to** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe] ** If this link doesn't work then send a message to: ** program-l-request@xxxxxxxxxxxxx ** and in the Subject line type ** unsubscribe ** For other list commands such as vacation mode, click on the ** immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq] ** or send a message, to ** program-l-request@xxxxxxxxxxxxx with the Subject:- faq