[C++-sig] Re: [BPL] python::interpreter proposal

Nicodemus nicodemus at globalite.com.br
Thu Jan 2 20:02:38 CET 2003


Dirk Gerrits wrote:

> Hmm that's quite a showstopper. Perhaps a second enum parameter is 
> needed? Something like:
>
> enum code_type
> { single_expression, single_statement, multiple_statements };
>
> Not very nice IMHO so if anyone knows a way around it, please 
> enlighten me. ;)
>
> Dirk Gerrits
>
>
I think two separate functions would be better.

void interpreter::exec( const std::string& code, dict& globals, dict& 
locals );
- Executes the given code in the context of the two given dictionaries.

object interpreter::eval( const std::string& expr, dict& globals, dict& 
locals );
- Evaluates the Python expression given, in the context of the two 
dictionaries, and returns the resulting object.

They're equivalent to the "exec" statement and to the "eval" builtin 
function in python.

Farewell,
Nicodemus.







More information about the Cplusplus-sig mailing list