Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: __all__ attribute: bug and proposal Date: Tue, 28 Jun 2016 07:32:42 +1000 Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de TZQn34WsTGj/UT27mS0oTQsTnQq5B9eUkLp5tTC1h72w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:bug': 0.05; 'cc:addr:python-list': 0.09; '__all__': 0.09; 'integers': 0.09; 'pavel': 0.09; 'typeerror:': 0.09; '2016': 0.16; '6:56': 0.16; 'earlier:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'name),': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'string,': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'pass': 0.22; 'am,': 0.23; '(you': 0.23; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'module': 0.25; 'message- id:@mail.gmail.com': 0.27; 'directly,': 0.29; 'objects': 0.29; 'classes': 0.30; 'work.': 0.30; 'putting': 0.30; 'class': 0.33; 'foo': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'possible': 0.36; 'subject:: ': 0.37; 'names': 0.38; 'note:': 0.66; '(a,': 0.84; 'chrisa': 0.84; 'to:none': 0.91; 'canonical': 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=ERco+HU/ZwoYOmqh0jqhlORWw7dPd7KcJxrfbAIg+LA=; b=TRh9MR2ykJqsWNSkG5P+zRKGlKgmYZ5Z8RUmK8De/LteU8yFt5PXN4yNURfS2UFPDe 29WbQrzsT+JejEfgQYwh/MVx0y7SSrWqYuqQD22m6e48x5KhIfWTXzqxWXkq3UBx9ekV osSijrR8ZcIjAtOEFPZ2iMusfICojKGt+FbgLnWJtmhvF1DJpXC0mS/yeZ09ijlcbIIO DdaLDW5u3aBsWCR4ULnt8rp2IkBWI5p5fJY4t6q4dzrYUsrXF9qI9V5MBux0lmXsZPtq O1cQTzGCKDz/RKRpsMn8fEJCzulxZygXG9RQgo8SY0DORQC7WLZ8bgAiTX4KWsq5KVLI CA/w== 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=ERco+HU/ZwoYOmqh0jqhlORWw7dPd7KcJxrfbAIg+LA=; b=mwiTMccHj0vjdZOgr7enuuAk1zRfNd9b62l26PQTdNstuGqB+FN3uom8t0z0kvZ6am h6tL2XEYkRJZ4w/sI3sI977+K5cZSJ9Pi3jINh306kopuP6eOdU87yTYYcrS9zia2bMs jm4HhnQEWVkkHljiACettyyfobHOi7JE/p9ApxYpX6QBnMUsg/God4UUYmy0g3TJJpe3 LFZDU5x4X4sOsu7vcYTWiN83GZ/mA9f7lShYB6lB23kw6ZtLV7oqJHWC1HRWRqqbqwVi 5yHQURlqL9xBArGRynLVa+gTf9qh6bdC57NKcbJTRRSJQOK+Ln2lEVfPKj87+VGPVJxI tyDA== X-Gm-Message-State: ALyK8tJtzmoZi6xLY0awE/9FG65DP8JMZc7psfoJWZGExoccgM4ZI/7IMYg+FmQYToAEhGulm8ForingwrHehg== X-Received: by 10.28.30.149 with SMTP id e143mr12097727wme.81.1467063163849; Mon, 27 Jun 2016 14:32:43 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:110611 On Tue, Jun 28, 2016 at 6:56 AM, Pavel S wrote: > Porposal: allow putting objects into __all__ directly, so possible problems will be found earlier: > > # module foo.py > class A: pass > class B: pass > class C: pass > > __all__ = (A, B, C) > > Note: this currently don't work. > >>>> from foo import * > TypeError: attribute name must be string, not 'type' How would it know what names to import them under? It's all very well with classes and functions (you could mandate that it uses the canonical name), but what about integers or strings? ChrisA