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 6996461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:09:33+00:00 2026-05-27T20:09:33+00:00

Kind of related to this question: https://stackoverflow.com/questions/8708525/how-to-check-if-mako-function-exist I want to check if a function

  • 0

Kind of related to this question:

https://stackoverflow.com/questions/8708525/how-to-check-if-mako-function-exist

I want to check if a function exists for a given class, but not inherited, so that the parent can called the child’s function, since otherwise it would result in an infinite recursion..

edit:

it actually gives a maximum stack level error, which is the same.

the equivalent code would be:

class A(object):
    def f(x):
        b = B()
        b.f()

class B(A):
    pass

a = A()
a.f()

i understand this is not clean or preferred, but it is what the template translates to, and I dunno how to check for it otherwise.

  • 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-27T20:09:34+00:00Added an answer on May 27, 2026 at 8:09 pm

    I want to check if a function exists for a given class, but not inherited

    Yes, you can check the class dictionary directly. Either use the __dict__ attribute or the built-in vars() function::

    >>> class A(object):
            def f(x):
                pass
    
    >>> class B(A):
            def g(x):
                pass
    
    >>> 'f' in vars(B)
    False
    >>> 'g' in vars(B)
    True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is kind of related to another question but I have a specific
This is kind of related to my previous question, but not really. I have
This question is kind of related to our web application and it is bugging
This question is kind of related to Handle URI hacking gracefully in ASP.NET in
Related to this question: URL characters replacement in JSP with UrlRewrite I want to
Actually this is more than one question, but seems kind related. I appreciate any
This is kind-of related to this question , on how to merge two dictionaries
This related question How can I apply a function to every row/column of a
This is kind of a two part question. But it both relates to the
Kind of related to my other question - I've only ever used HTMLControls with

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.