Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2361
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'exec': 0.07; 'imports': 0.07; 'python': 0.07; 'dict': 0.09; 'finally:': 0.09; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'underlying': 0.09; 'pm,': 0.11; 'written': 0.12; 'def': 0.13; 'wrote:': 0.14; 'defined': 0.15; '456': 0.16; '458': 0.16; '460': 0.16; 'enigma': 0.16; 'filename,': 0.16; 'kern': 0.16; 'nameerror': 0.16; 'prof': 0.16; 'received:216.62': 0.16; 'received:216.62.213': 0.16; 'received:enthought.com': 0.16; 'recently.': 0.16; 'shells': 0.16; 'skip:/ 50': 0.16; 'traceback': 0.16; '(most': 0.16; 'code.': 0.18; 'everyone,': 0.19; 'interpret': 0.19; 'shell': 0.19; 'programming': 0.20; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'skip:- 70': 0.24; 'subject:problem': 0.25; 'statement': 0.26; 'there.': 0.26; "i'm": 0.26; "i'll": 0.26; 'url:mailman': 0.27; 'pass': 0.27; 'looks': 0.28; 'explicitly': 0.29; 'list': 0.30; 'cmd': 0.31; 'feature,': 0.31; 'however,': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'url:listinfo': 0.33; 'bit': 0.33; 'header:X-Complaints-To:1': 0.34; 'actually': 0.34; 'regular': 0.34; 'header:User-Agent:1': 0.35; 'module.': 0.35; 'try:': 0.35; 'questions.': 0.36; 'problem.': 0.36; 'run': 0.37; 'but': 0.38; 'url:org': 0.38; 'received:org': 0.38; 'though': 0.38; 'set': 0.39; 'skip:s 30': 0.39; 'to:addr:python.org': 0.39; 'header:Mime- Version:1': 0.39; 'except': 0.39; 'similar': 0.40; 'attempt': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'fake': 0.60; 'order': 0.61; 'our': 0.63; 'world': 0.65; 'subject:about': 0.66; 'believe': 0.66; 'profile': 0.68; 'hey,': 0.74; '--->': 0.84; 'dict,': 0.84; 'eco': 0.84; 'honestly,': 0.84; 'locals': 0.84; 'nice,': 0.84; 'timer,': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: A problem about ipython |
| Date | Fri, 01 Apr 2011 10:16:38 -0500 |
| Organization | The Church of Last Thursday |
| References | <43e40bbd-ae57-47dd-9e03-2d480278e4b6@j11g2000prn.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | outbound.enthought.com |
| User-Agent | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
| In-Reply-To | <43e40bbd-ae57-47dd-9e03-2d480278e4b6@j11g2000prn.googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.78.1301671014.2990.python-list@python.org> (permalink) |
| Lines | 62 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1301671014 news.xs4all.nl 81485 [::ffff:82.94.164.166]:49147 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:2361 |
Show key headers only | View raw
On 3/31/11 8:48 PM, Vincent Ren wrote:
> Hey, everyone, I'm trying to use ipython recently. It's very nice,
> however, when I run this(from Programming Python 3rd) in ipython, I'll
> get a NameError:
>
>
> In [1]: import settime, timer, set
>
> In [2]: import profile
>
> In [3]: profile.run('timer.test(100, settime.setops, set.Set)')
> ---------------------------------------------------------------------------
> NameError Traceback (most recent call
> last)
>
> /home/vincent/hacking/python/<ipython console> in<module>()
>
> /usr/lib/python2.6/profile.pyc in run(statement, filename, sort)
> 68 prof = Profile()
> 69 try:
> ---> 70 prof = prof.run(statement)
> 71 except SystemExit:
> 72 pass
>
> /usr/lib/python2.6/profile.pyc in run(self, cmd)
> 454 import __main__
> 455 dict = __main__.__dict__
> --> 456 return self.runctx(cmd, dict, dict)
> 457
> 458 def runctx(self, cmd, globals, locals):
>
> /usr/lib/python2.6/profile.pyc in runctx(self, cmd, globals, locals)
> 460 sys.setprofile(self.dispatcher)
> 461 try:
> --> 462 exec cmd in globals, locals
> 463 finally:
> 464 sys.setprofile(None)
>
> /usr/lib/pymodules/python2.6/IPython/FakeModule.pyc in<module>()
>
> NameError: name 'timer' is not defined
In order to support pickling and its %run feature, IPython makes a fake __main__
module. It looks like profile.run() explicitly imports __main__ to try to run
the statement there. Honestly, it's been a thorn in our side for a long time,
but it's a confusing bit of the code. Most interactive shells actually written
in Python are going to have a similar need to do a workaround, since they
already have a __main__. The regular shell is not written in Python, so it has
no problem.
You will want to ask on the IPython list for future IPython questions.
http://mail.scipy.org/mailman/listinfo/ipython-user
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A problem about ipython Vincent Ren <renws1990@gmail.com> - 2011-03-31 18:48 -0700
Re: A problem about ipython Robert Kern <robert.kern@gmail.com> - 2011-04-01 10:16 -0500
Re: A problem about ipython Vincent Ren <renws1990@gmail.com> - 2011-04-02 15:19 -0700
csiph-web