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

  • Home
  • SEARCH
  • 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 834199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:38:18+00:00 2026-05-15T04:38:18+00:00

I have the following class; class myStringMethod(): def __init__(self): self.func_list= [(‘func1′,’print_func1()’),(‘func2′,’print_func2()’)] def print_func1(self, name):

  • 0

I have the following class;

class myStringMethod():
    def __init__(self):
        self.func_list= [('func1','print_func1()'),('func2','print_func2()')]

    def print_func1(self, name):
        print name

    def print_func2(self, name):
        print name

    def call_func_by_name(self):
        for func in self.func_list:
            getattr(self, func[1])('Func Name')

if __name__=='__main__':
    strM = myStringMethod()
    strM.call_func_by_name() #Nothing prints out!

No functions get called out, what am i missing?

gath

  • 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-15T04:38:19+00:00Added an answer on May 15, 2026 at 4:38 am

    your self.func_list should be:

    self.func_list= [('func1','print_func1'),('func2','print_func2')]
    

    And the way your code is written it will, of course, print 'Func Name'. I guess you probably meant to pass func[0] there.

    Working example:

    >>> class myStringMethod():
        def __init__(self):
            self.func_list= [('func1','print_func1'),('func2','print_func2')]
    
        def print_func1(self, name):
            print(name)
    
        def print_func2(self, name):
            print(name)
    
        def call_func_by_name(self):
            for func in self.func_list:
                getattr(self, func[1])('Func Name')
    
    >>> myStringMethod().call_func_by_name()
    Func Name
    Func Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Operator overloading methods have to live inside the class they… May 16, 2026 at 10:28 am
  • Editorial Team
    Editorial Team added an answer It's a bug in current PDT Release in Helios. May 16, 2026 at 10:28 am
  • Editorial Team
    Editorial Team added an answer new double*[num] is an array of double pointers i.e. each… May 16, 2026 at 10:28 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following class in Java code: public class CHRTreeCreator extends IndexCreator { ...
If have following class public abstract class MyBaseClass : BaseClass { public override string
I have following class (as seen through reflector) public class W : IDisposable {
I have following class, I need to get type in constructor, how can I
I have following class: template <size_t size> class Araye{ public: Araye(int input[]){ for (int
Suppose you have following class: class ProcessController { public List<Process> Active { get {
I have the following class: <?php /* * Abstract class that, when subclassed, allows
I have the following code: class Program { static void Main(string[] args) { string
I have the following controller: class FooController : Controller { public ActionResult SomeAction(id) {

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.