On Wed, 26 Sep 2001, John Goerzen wrote:
> In Jython:
>
> Jython 2.1a3 on java1.1.8 (JIT: null)
> Type "copyright", "credits" or "license" for more information.
> >>> dir("")
> []
An implementation quirk. If dir() doesn't reveal an object's
methods, add ".__class__" to get a closer look.
For example:
>>> dir("".__class__)
['__add__', '__cmp__', '__complex__', '__contains__', '__len__',
'__mod__', '__repr__', '__str__', 'alnum', 'alpha', 'capitalize',
'center', 'classDictInit', 'count', 'decimal', 'digit', 'encode',
'endswith', 'expandtabs', 'find', 'index','isalnum', 'isalpha',
'isdecimal', 'isdigit', 'islower', 'isnumeric', 'isspace', 'istitle',
'isunicode', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'numeric',
'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'space', 'split',
'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate',
'unicode', 'upper', 'zfill']
> >>> ".".join(['1', '2', '3', '4'])
> '1.2.3.4'
> >>> dir([])
> ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>
> In Python:
>
> Python 2.0.1 (#0, Jun 23 2001, 23:50:30)
> [GCC 2.95.4 20010319 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> dir("")
> ['capitalize', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper']
> >>> ".".join(['1', '2', '3', '4'])
> '1.2.3.4'
> >>> dir([])
> ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>
> Why is Jython's dir() not showing methods that clearly exist? The
> last version of Python that didn't show those on dir("") didn't
> actually have them.
>
>
|