Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7457871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:22:39+00:00 2026-05-29T13:22:39+00:00

The dir() function in python retrieves all attributes for a class. I was wondering

  • 0

The “dir()” function in python retrieves all attributes for a class. I was wondering if there was a similar function that returns only user defined functions? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:22:39+00:00Added an answer on May 29, 2026 at 1:22 pm

    If you want to tell a builtin from a user-defined function I’d use the types module.
    For instance:

    >>> def hello():
    ...     print("hi")
    ... 
    >>> import types
    >>> type(hello) is types.BuiltinFunctionType
    False
    >>> type(hello) is types.FunctionType
    True
    

    Then it depends on what you want to do.You could use list comprehensions to check all attributes of a class and keep only those that turn out to be true.

    [ x for x in dir(yourclass) if (type(x) is types.FunctionType) ]
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How come the dir() function in Python doesn't show all of the callable attributes?
Is there is a tool similar to dir() for modules that will tell me
In Python there is a built-in function called dir . This is used to
Python comes with the handy dir() function that would list the content of a
some times i see that functions are defined as below: read_dir(dir) char *dir; {
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this
Is there a way to view the source code of a function, class, or
The globals function returns a dictionary that contains the functions in a module, and
I am working on some Python socket code that's using the socket.fromfd() function. However,
I have defined a .dir-locals.el file with the following content: ((python-mode . ((cr/virtualenv-name .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.