Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47865

Re: "Don't rebind built-in names*" - it confuses readers

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.95; '*S*': 0.01; 'skip:[ 20': 0.04; '[1,': 0.09; 'callable': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'janssen': 0.16; 'namespace,': 0.16; 'really?': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; '>>>': 0.22; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; '>>>>': 0.31; 'received:google.com': 0.35; 'skip:[ 10': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'name:': 0.61; 'qualified': 0.72; 'back?': 0.84; 'subject:Don': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=YaQHY3oQVhBjig1xvFLoUZG/PMJrNil6scuLforkylQ=; b=IvVulDWumdwH09UdHHX88ou16VA2RPOyDD/xapwqxsJagqSiSRdDRp741R1JOiQx5a j8ncsqC2283Pua4zFn+BMTO3kdpeMuVI/mataYyz9SjqLZLTXdls1zY7zXz15ginAsPs v3ao2x5z5J1gShozVN1tgDgAMOiBZmU6RWW5tLyvuyJU/17gKanNurtLOFVWauvwn8MN zSA9nwz9OLOB9xlgonmmoUgQ0c82sKqA686ARTdj0M37QshimOmoUO25S7vSyR734dFN 9ZvXW7eWmdP3ivdoWSaHE6h8GwqbyQp2g71zAeDLkFpfQ+D3P8VPMCyvbUDvh/rS3xn4 x23Q==
MIME-Version 1.0
X-Received by 10.220.109.66 with SMTP id i2mr10530960vcp.51.1371082094145; Wed, 12 Jun 2013 17:08:14 -0700 (PDT)
In-Reply-To <CAMjeLr9pURVnRmsFFuOt5vxGvDMmmyTzmR49-k5ourng98VsiQ@mail.gmail.com>
References <mailman.3001.1370909708.3114.python-list@python.org> <dffd70ad-4e9a-45cd-914b-7f1388ded5a2@a9g2000pbq.googlegroups.com> <51b69332$0$29997$c3e8da3$5496439d@news.astraweb.com> <CAMjeLr9pURVnRmsFFuOt5vxGvDMmmyTzmR49-k5ourng98VsiQ@mail.gmail.com>
Date Thu, 13 Jun 2013 10:08:14 +1000
Subject Re: "Don't rebind built-in names*" - it confuses readers
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.3145.1371082102.3114.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371082102 news.xs4all.nl 15974 [2001:888:2000:d::a6]:58219
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47865

Show key headers only | View raw


On Thu, Jun 13, 2013 at 10:04 AM, Mark Janssen
<dreamingforward@gmail.com> wrote:
> Really?
>
>>>> int="five"
>>>> [int(i) for i in ["1","2","3"]]
> TypeError:  str is not callable
>
> Now how are you going to get the original int type back?

Either del it from your module namespace, or use the qualified name:

>>> int="five"
>>> [__builtins__.int(i) for i in ["1","2","3"]]
[1, 2, 3]
>>> del int
>>> [int(i) for i in ["1","2","3"]]
[1, 2, 3]

It's shadowed, not overwritten.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"Don't rebind built-in names*" - it confuses readers Terry Jan Reedy <tjreedy@udel.edu> - 2013-06-10 20:14 -0400
  Re: "Don't rebind built-in names*" - it confuses readers rusi <rustompmody@gmail.com> - 2013-06-10 19:36 -0700
    Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-11 03:02 +0000
      Re: "Don't rebind built-in names*" - it confuses readers rusi <rustompmody@gmail.com> - 2013-06-10 20:30 -0700
        Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-11 05:52 +0000
        Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-11 17:20 +1000
      Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-11 13:57 +1000
      Re: "Don't rebind built-in names*" - it confuses readers Serhiy Storchaka <storchaka@gmail.com> - 2013-06-11 18:55 +0300
      Re: "Don't rebind built-in names*" - it confuses readers Mark Janssen <dreamingforward@gmail.com> - 2013-06-12 17:04 -0700
        Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-13 01:01 +0000
      Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-13 10:08 +1000
        Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-13 01:08 +0000
          Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-13 11:30 +1000
      Re: "Don't rebind built-in names*" - it confuses readers Skip Montanaro <skip@pobox.com> - 2013-06-12 19:18 -0500
      Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-13 10:33 +1000
      Re: "Don't rebind built-in names*" - it confuses readers Ethan Furman <ethan@stoneleaf.us> - 2013-06-12 17:30 -0700
  Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-11 02:56 +0000
    Re: "Don't rebind built-in names*" - it confuses readers Terry Jan Reedy <tjreedy@udel.edu> - 2013-06-11 02:06 -0400
    Re: "Don't rebind built-in names*" - it confuses readers Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-11 08:22 -0700
      Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-11 16:59 +0000
      Re: "Don't rebind built-in names*" - it confuses readers Chris Angelico <rosuav@gmail.com> - 2013-06-12 03:32 +1000

csiph-web