Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: Is vars() the most useless Python built-in ever? Date: Wed, 2 Dec 2015 05:34:25 -0600 Lines: 15 Message-ID: References: <565cf141$0$1612$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de NCLC9AEmh+xQe5noMIjDMAnsyAqDOn031mLMdekuYfTg== Return-Path: 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; 'subject:Python': 0.05; 'exception.': 0.07; "object's": 0.09; 'wed,': 0.15; '__slots__': 0.16; 'attributes.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sad': 0.16; 'subject:ever': 0.16; 'subject:most': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'library': 0.20; '2015': 0.20; 'to:name:python-list@python.org': 0.20; 'am,': 0.23; 'dec': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'post': 0.31; 'maybe': 0.33; 'useful': 0.33; 'raising': 0.33; 'add': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'there,': 0.37; 'environment.': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'subject:the': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'more': 0.63; 'union': 0.67; 'grow': 0.75 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:to :content-type; bh=96Tn1PWBSQlNbPsdePB6p3DsdI7SyUO8g9BagPNEVA0=; b=o1lAv28IYRciw1jVVuD+U6WCaxNu4lRRgCwhE4JmXeSqlDk8IeKVvVSdyNzvw/41Ir QJFZ1kZAEGOY8albl4IjFEc3j8u61x4IVoM4V2q4h//WIeoBiiJ2GrXHavJ7JKK75sxd lqvcwEz2c/ItFX8lsa/oWFJu1585kDKQBtvi/JPKI5N0E5Y2sSrpQs5BIoFz0Dl8I4EW stSpZN/cCYh8OeJnIzywS8ggbbMnNMwjKgQwioxacru0oNcKIeD1KhD9CU6TO1+egRoi Ags6Sdk00/MYfIq46cl0UArKfEjUPeolhcw2WDZ7egTAZd8vr5qe1UOcx9FuKs65YD4a TbgQ== X-Received: by 10.50.157.34 with SMTP id wj2mr30265771igb.32.1449056105678; Wed, 02 Dec 2015 03:35:05 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99871 On Wed, Dec 2, 2015 at 3:28 AM, Chris Angelico wrote: > On Wed, Dec 2, 2015 at 7:22 PM, Serhiy Storchaka wrote: >> >> I use vars() exclusively for introspection in interactive environment. As >> well as dir() and help(). Sad that it doesn't work with __slots__. > > Maybe the upshot of all this is a post to python-ideas recommending > that vars() grow support for __slots__ types? If it's most often used > interactively, this would make it more useful there, and it wouldn't > break backward compatibility unless there's some way that people are > depending on it raising an exception. Let vars() continue in its antediluvian ways. Maybe the standard library could add an inspect.getdata function that returns a union of an object's __dict__ items and data-descriptor attributes.