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


Groups > comp.lang.python > #110633

Re: __all__ attribute: bug and proposal

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: __all__ attribute: bug and proposal
Date Tue, 28 Jun 2016 12:20:48 +1000
Lines 21
Message-ID <mailman.54.1467080456.2358.python-list@python.org> (permalink)
References <d5e97a5e-6f10-4e3f-ab24-113632f16f29@googlegroups.com> <CAPTjJmqLmg5tPhLnvpMOg_+NhYiNOZW_RG2yDbBiqD6MYqtxSg@mail.gmail.com> <788b5c19-3f92-9319-a791-03bac9ee24b4@mrabarnett.plus.com> <CAPTjJmoaPt_hR7o9qZnORfR2rvHn7iCmmDJnRdK19yCpOfxe=Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de rbC0Zl8ot0cXjI8Nt5Oc7wRzQJxktSiwvWMepiuEBsFg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'subject:bug': 0.05; 'so?': 0.07; 'cc:addr:python-list': 0.09; 'scripts': 0.09; '__all__': 0.09; 'namespace': 0.09; 'worse': 0.09; 'def': 0.13; '2016': 0.16; 'err...': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'function,': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'end,': 0.29; 'classes': 0.30; 'skip:_ 30': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'primarily': 0.35; 'problem.': 0.35; 'subject:: ': 0.37; 'available.': 0.37; "won't": 0.38; 'still': 0.40; "'all'": 0.84; 'chrisa': 0.84; 'worried': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=OitTTdajGG+ar38lHjVSjdvt7KmD9/Fy83TqHiEnvEo=; b=dkPN4y6ALlzi1fy2Zu8VyRfi99KwhHneNN4kYDVCmuqwimJWdV8St8N0qweJCsraK9 XzfiakGhR8ieoOyc+IvaDmFar/GJlYe1vYFX3X01mK7gtQM/QTPWZbEFIELjmYBfOYBC dH55tlMqVPJYs5pA8Xhikw9prkdg+ozedvR9WNPrH1FRd9a0FLzqKyth0JFHiJ9D8yLb /kDF1PETHms0S+A/vTB76F/JkM8x7TRDHOZeAo2g/WNgJ3P+ulCAmDID/DCgAskbVaSR Rig1HUFqWwPI2jlMXo+qpRK34B/2r8hrHbLfxcFIiGT9QxTtlS5lIYsRKKsE6/4Pw6oe Pv4g==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=OitTTdajGG+ar38lHjVSjdvt7KmD9/Fy83TqHiEnvEo=; b=VlaQFuwAfEKICZa3o7WjwW5cs3dNJ1G3PgwSmb24fznJCmZpI82sCoZMdEtQnA3XOs OF8KBD9X55FIAcV7a/2YNo2GpaVNtX5UEjosKtpDB+lc/GJma3HXSpjnDS6tXWcldw1v mPxsOt5nNIH0YeX5dq4slt7N6r/CW+fVmgH8vCVMuuCeRPqZwOodd18AWV2nNlR51b4x s16jLj/eDsGmj9Ea4MOGagWFUSzLstOeqvKbeLMJ/HlLuyXIymComNP8l7z/ynfI6ae5 3iVWyDhyV0mniyEDqjnLzNeiO2ChDJ68Zi1aimnoPp09lOItt4aYRILPUVk/WkeqoCMK 4OLw==
X-Gm-Message-State ALyK8tLhIG7lvCT0P6RpmzZW/2emnLbAOPGLEomobUMqGY94+QCRAIqiBQ0S55OQY8r7uvDtUAgvO3Dbk5RavA==
X-Received by 10.28.44.87 with SMTP id s84mr738435wms.61.1467080449014; Mon, 27 Jun 2016 19:20:49 -0700 (PDT)
In-Reply-To <788b5c19-3f92-9319-a791-03bac9ee24b4@mrabarnett.plus.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAPTjJmoaPt_hR7o9qZnORfR2rvHn7iCmmDJnRdK19yCpOfxe=Q@mail.gmail.com>
X-Mailman-Original-References <d5e97a5e-6f10-4e3f-ab24-113632f16f29@googlegroups.com> <CAPTjJmqLmg5tPhLnvpMOg_+NhYiNOZW_RG2yDbBiqD6MYqtxSg@mail.gmail.com> <788b5c19-3f92-9319-a791-03bac9ee24b4@mrabarnett.plus.com>
Xref csiph.com comp.lang.python:110633

Show key headers only | View raw


On Tue, Jun 28, 2016 at 11:55 AM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2016-06-28 01:32, Chris Angelico wrote:
> [snip]
>
>> If you're primarily worried about classes and functions, here's a neat
>> trick you can use:
>>
>> __all__ = []
>> def all(thing):
>>     __all__.append(thing.__name__)
>>     return thing
>>
> Err... won't that hide the 'all' builtin?
>

Yep. So? If you're not using it *at top level*, it's not a problem. I
clean up the namespace at the end, so if you use it inside a function,
it'll still be available. And most of my scripts don't use 'all'
anyway... it's no worse than using 'id' for a database ID.

ChrisA

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


Thread

__all__ attribute: bug and proposal Pavel S <pavel@schon.cz> - 2016-06-27 13:56 -0700
  Re: __all__ attribute: bug and proposal Chris Angelico <rosuav@gmail.com> - 2016-06-28 07:32 +1000
    Re: __all__ attribute: bug and proposal Pavel S <pavel@schon.cz> - 2016-06-27 15:29 -0700
      Re: __all__ attribute: bug and proposal Chris Angelico <rosuav@gmail.com> - 2016-06-28 08:41 +1000
      Re: __all__ attribute: bug and proposal Terry Reedy <tjreedy@udel.edu> - 2016-06-27 22:46 -0400
        Re: __all__ attribute: bug and proposal Steven D'Aprano <steve@pearwood.info> - 2016-06-28 13:24 +1000
  Re: __all__ attribute: bug and proposal Random832 <random832@fastmail.com> - 2016-06-27 20:25 -0400
  Re: __all__ attribute: bug and proposal Chris Angelico <rosuav@gmail.com> - 2016-06-28 10:32 +1000
  Re: __all__ attribute: bug and proposal MRAB <python@mrabarnett.plus.com> - 2016-06-28 02:55 +0100
  Re: __all__ attribute: bug and proposal Steven D'Aprano <steve@pearwood.info> - 2016-06-28 11:56 +1000
  Re: __all__ attribute: bug and proposal Chris Angelico <rosuav@gmail.com> - 2016-06-28 12:20 +1000
  Re: __all__ attribute: bug and proposal Random832 <random832@fastmail.com> - 2016-06-27 22:27 -0400
  Re: __all__ attribute: bug and proposal Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-06-27 23:31 -0500
  Re: __all__ attribute: bug and proposal Ethan Furman <ethan@stoneleaf.us> - 2016-06-28 08:29 -0700

csiph-web