Re: Getting a list of an object's methods?

Discussion in 'Python' started by Jeremy Yallop, Jun 23, 2003.

  1. Alexander Schmolck wrote:
    > The premises are right, but they don't entail the conclusion. `dir`s behavior
    > is not guaranteed to be stable, but `inspect.getmembers`'s obviously is [1].


    [further logic and "obvious" things snuipped]

    All very well, but inspect.getmembers is implemented using dir() /now/,
    and doesn't return all of the methods in the /currently-existing/
    versions of Python that the OP wants to use. It isn't an appropriate
    solution, unfortunately.

    > I don't think "What methods does this object have?" is a question
    > that only a python wizard should be able to ask and receive a
    > well-defined answer.


    Well, that's certainly true.

    Jeremy.
    Jeremy Yallop, Jun 23, 2003
    #1
    1. Advertising

  2. Jeremy Yallop

    Freddie Guest

    Jeremy Yallop <> wrote in
    news:bd7qdu$pkgc5$:

    > Alexander Schmolck wrote:
    >> The premises are right, but they don't entail the conclusion. `dir`s
    >> behavior is not guaranteed to be stable, but `inspect.getmembers`'s
    >> obviously is [1].

    >
    > [further logic and "obvious" things snuipped]
    >
    > All very well, but inspect.getmembers is implemented using dir() /now/,
    > and doesn't return all of the methods in the /currently-existing/
    > versions of Python that the OP wants to use. It isn't an appropriate
    > solution, unfortunately.
    >
    >> I don't think "What methods does this object have?" is a question
    >> that only a python wizard should be able to ask and receive a
    >> well-defined answer.

    >
    > Well, that's certainly true.
    >
    > Jeremy.
    >


    The dir(self.__class__) works OK for me, since they're all wacky custom
    classes. I would still like to know why, in Python 2.1, none of the methods
    show up for when using dir() (or __dict__) on an instance of the class. It's
    really quite odd :)

    >>> len(dir(blah)), len(dir(blah.__dict__))

    (24, 24)
    >>> len(dir(blah.__class__)), len(dir(blah.__class__.__dict__))

    (49, 49)

    Thanks to the various people who helped me out again :)

    Freddie

    --------------------------------------------------------------
    Remove the z's from my e-mail address if you really want to
    Freddie, Jun 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeremy Yallop

    Re: Getting a list of an object's methods?

    Jeremy Yallop, Jun 23, 2003, in forum: Python
    Replies:
    0
    Views:
    1,144
    Jeremy Yallop
    Jun 23, 2003
  2. Michele Simionato

    Re: Getting a list of an object's methods?

    Michele Simionato, Jun 24, 2003, in forum: Python
    Replies:
    0
    Views:
    617
    Michele Simionato
    Jun 24, 2003
  3. DG
    Replies:
    3
    Views:
    317
    Terry Reedy
    Jul 22, 2009
  4. Nikita Petrov
    Replies:
    2
    Views:
    100
    Gary Wright
    Apr 6, 2008
  5. Kenneth McDonald
    Replies:
    5
    Views:
    289
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page