Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5278
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.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.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python': 0.07; '3.x': 0.09; 'attribute': 0.09; 'builtin': 0.09; 'notation.': 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; "'s')": 0.16; '(note': 0.16; '__builtins__': 0.16; 'from:addr:yahoo.com.ar': 0.16; 'thu,': 0.22; 'trying': 0.23; 'literal': 0.23; 'module,': 0.23; 'skip:b 20': 0.27; 'function': 0.27; 'error': 0.29; 'detail.': 0.31; 'imported': 0.31; 'url:library': 0.31; 'import': 0.32; 'called': 0.32; 'to:addr :python-list': 0.32; 'another': 0.32; 'url:docs': 0.33; 'module': 0.33; 'using': 0.34; 'header:X-Complaints-To:1': 0.34; 'header :User-Agent:1': 0.35; 'fails': 0.35; 'however': 0.37; 'url:python': 0.37; 'url:org': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'works': 0.40; 'header:Received:5': 0.40; 'note:': 0.61; '2011': 0.62; 'dot': 0.68; 'received:190': 0.69; '-0300,': 0.84; 'genellina': 0.84; 'min': 0.84; 'gabriel': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> |
| Subject | Re: Peculiar Behaviour of __builtins__ |
| Date | Thu, 12 May 2011 22:59:24 -0300 |
| References | <BANLkTinHZzc=yry29jkZnCy=Z7E7Ue0vUQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1; format=flowed; delsp=yes |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | 190.2.4.25 |
| User-Agent | Opera Mail/11.10 (Win32) |
| 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.1504.1305251910.9059.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1305251911 news.xs4all.nl 81473 [::ffff:82.94.164.166]:52599 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:5278 |
Show key headers only | View raw
En Thu, 12 May 2011 20:29:57 -0300, Aman Nijhawan <amannijhawan@gmail.com> escribió: > I was trying to call the builtin function min by using > getattr(__builtins__,'min') > > This works at the interpretter prompt > > However when I called it inside a module that was imported by another > module > it fails and gives an attribute error __builtins__ (note the final 's') is an implementation detail. You want the __builtin__ (no 's') module, renamed 'builtin' in Python 3.x py> import __builtin__ py> builtin_min = __builtin__.min py> builtin_min([8,2,5]) 2 See http://docs.python.org/library/__builtin__.html Note: using getattr with a literal name is not so useful. Better to use dot notation. -- Gabriel Genellina
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Peculiar Behaviour of __builtins__ "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-05-12 22:59 -0300
csiph-web