Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Re: dir() vs print(dir()) in the embedded mode (

MRAB 03-29-2013 09:24 PM

Re: dir() vs print(dir()) in the embedded mode
On 29/03/2013 21:04, Nick Gnedin wrote:
> Folks,
> I have a newbie question: I am trying to embed Python into my
> application. While playing around, I noticed that the behavior of the
> interpreter in the embedded mode differs from the standalone one.
> Namely, in the standalone mode if I type dir(), I get a list of build-in
> symbols. In the embedded mode only print(dir()) does that, while just
> dir() returns silently.
> Is there a way to intercept the output of dir() (and all other commands)
> and display them to the user?
> Here is an example code that illustrates the behavior (the first call to
> PyRun_SimpleString() returns silently).
> Many thanks for your future hints,

dir() doesn't print anything, it just returns a list.

It's the interactive interpreter that's printing the result, unless
it's None.

All times are GMT. The time now is 01:11 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.