Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'newbie': 0.05; 'output': 0.05; 'result,': 0.07; 'python': 0.11; 'differs': 0.16; 'folks,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'illustrates': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'nick': 0.16; 'none.': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'user?': 0.16; 'wrote:': 0.18; 'trying': 0.19; '(the': 0.22; 'example': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'mode': 0.30; 'code': 0.31; 'embed': 0.31; 'question:': 0.31; 'noticed': 0.34; 'subject:the': 0.34; 'display': 0.35; 'received:84': 0.35; 'there': 0.35; 'thanks': 0.36; 'list': 0.37; 'list.': 0.37; 'to:addr:python-list': 0.38; 'that,': 0.38; 'does': 0.39; 'embedded': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'future': 0.60; 'first': 0.61; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reply- to:no real name:2**0': 0.71; 'behavior': 0.77; 'around,': 0.84; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=HO4d4PRv c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=B68SgI_Jlq8A:10 a=Npl5Oc42KcgA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=nZ5ywAmkYwsA:10 a=UX-C7oAYt_2goEnDNToA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Fri, 29 Mar 2013 21:24:33 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: dir() vs print(dir()) in the embedded mode References: <515601D8.2000005@gmail.com> In-Reply-To: <515601D8.2000005@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364592269 news.xs4all.nl 6948 [2001:888:2000:d::a6]:57470 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42280 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.