

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
6 messages in org.python.python-bugs-list[ python-Bugs-925537 ] dir(mod) OK or...| From | Sent On | Attachments |
|---|---|---|
| SourceForge.net | Mar 29, 2004 2:28 pm | |
| SourceForge.net | Mar 29, 2004 2:39 pm | |
| SourceForge.net | Mar 29, 2004 3:02 pm | |
| SourceForge.net | Mar 29, 2004 4:34 pm | |
| SourceForge.net | Mar 29, 2004 5:11 pm | |
| SourceForge.net | Mar 30, 2004 11:02 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [ python-Bugs-925537 ] dir(mod) OK or use vars(mod).keys()? | Actions... |
|---|---|---|
| From: | SourceForge.net (nore...@sourceforge.net) | |
| Date: | Mar 29, 2004 4:34:33 pm | |
| List: | org.python.python-bugs-list | |
Bugs item #925537, was opened at 2004-03-29 14:28 Message generated for change (Settings changed) made by jimjjewett You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=925537&group_id=5470
Category: Python Library Group: Python 2.4 Status: Open Resolution: None
Priority: 4
Submitted By: Jim Jewett (jimjjewett) Assigned to: Nobody/Anonymous (nobody) Summary: dir(mod) OK or use vars(mod).keys()?
Initial Comment: The documentation on dir() notes that its behavior may change across releases.
Several library modules use dir(x) in ways that might break if it changed too much.
Should these be changed to use vars(obj).keys() (and possibly sort()), or should the note on dir() be removed?
My own preference would just be to provide some guidance, such as "The output of dir() will always include all public variables which do not have a magic meaning."
I realize that the standard library itself could be updated if dir() changes in an uncomfortable way. My real concern is which spelling to use in my own code. The library examples suggest a simpler (and clearer) dir(), but the documentation still says otherwise.
A quick search for modules using dir() showed possible trouble in at least cgitb, cmd, FCNTL, inspect, optparse, os, pickle, rlcompleter, SimpleXMLRPCServer, TERMIOS, tokenize, unittest, and urllib2.
----------------------------------------------------------------------
Comment By: Jim Jewett (jimjjewett) Date: 2004-03-29 14:58
Message: Logged In: YES user_id=764593
Correction: "The output of dir (module) will always include ..."
The most common use is figuring out what to do with (import from) a module.
Symmetry suggests the same for a no-argument call or a class or type object, but object instances do not use their __dict__ for their attributes; the results are already different there.
-jJ
----------------------------------------------------------------------
Comment By: Jim Jewett (jimjjewett) Date: 2004-03-29 14:39
Message: Logged In: YES user_id=764593
If there concern is over attributes that are "public" but don't exist until called, then most uses of dir and vars are already broken. An alternative reasonable promise would be
The output of dir(obj) will always include all (public?, non-magical?) names in vars(obj).keys().
----------------------------------------------------------------------
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=925537&group_id=5470







