Re: dir() vs print(dir()) in the embedded mode

Discussion in 'Python' started by MRAB, Mar 29, 2013.

  1. MRAB

    MRAB Guest

    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.
    MRAB, Mar 29, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    472
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    459
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    514
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    427
    Edward Loper
    Aug 9, 2007
  5. Nick Gnedin
    Replies:
    2
    Views:
    160
Loading...

Share This Page