[program-l] Re: quick python question

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Tue, 24 Mar 2009 10:08:22 -0500 (EST)

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

Other related posts: