Bugs item #925537, was opened at 2004-03-29 14:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
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: 5
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.
----------------------------------------------------------------------