<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">I'm +1. This bites me far too often.<br><br>> in the past developers<br>were encouraged to put only "useful" attributes in __dir__.<br><br>Good. If I'm getting vars() I really only want the useful ones. If I need interesting/secret ones then I'll getattr for them.<br><br>Cheers,<br>Steve<br><br>Top-posted from my Windows Phone</div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:alexander.belopolsky@gmail.com">Alexander Belopolsky</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">12/12/2016 19:47</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:steve@pearwood.info">Steven D'Aprano</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:python-ideas@python.org">python-ideas</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: [Python-ideas] Enhancing vars()</span><br><br></div><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 12, 2016 at 6:45 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div class="a3s aXjCH m158f56da2a9a003e" id=":1mw">Proposal: enhance vars() to return a proxy to the object namespace,<br>
regardless of whether said namespace is __dict__ itself, or a number of<br>
__slots__, or both.</div></blockquote></div><br>How do you propose dealing with classes defined in C? Their objects don't have __slots__.</div><div class="gmail_extra"><br></div><div class="gmail_extra">One possibility is to use __dir__ or dir(), but those can return anything and in the past developers</div><div class="gmail_extra">were encouraged to put only "useful" attributes in __dir__.</div></div>
</body></html>