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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:09:02+00:00 2026-06-04T00:09:02+00:00

class A(): class B(): def Foo(self): print Hello class C(): def Bar(self): print Goodbye

  • 0
class A():
    class B():
       def Foo(self):
           print "Hello"
    class C():
       def Bar(self):
           print "Goodbye"
    def name(self):
        print "FooBar"

What I want to do is, within the Bar function is call the Foo function. How would I do that?

  • 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-06-04T00:09:03+00:00Added an answer on June 4, 2026 at 12:09 am

    In Python, inner classes don’t have an implicit instance of the outer class associated with them. Without such an instance, you can’t call A‘s non-static methods from B or C.

    If you do have such an instance, then simply use the dot notation:

    class C():
       def Bar(self):
           self.a.name()
       ...
    

    (where self.a is an instance of A.)

    Alternatively, if A.name() can be made static, the following will also work:

    class A(object):
    
        class C():
           def Bar(self):
               print "Goodbye"
               A.name()
    
        @staticmethod
        def name():
            print "FooBar"
    
    A.C().Bar()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Foo(object): pass foo = Foo() def bar(self): print 'bar' Foo.bar = bar foo.bar()
I will go straight to the example: class Foo: @execonce def initialize(self): print 'Called'
I have the following structure: class foo(object): class bar(object): def __init__(self, parent): self._parent=parent #this
So, say I have models like this: class Foo(Model): name = CharField(max_length=200) def latest_comment(self):
class Foo def initialize(a) puts Hello #{a} end end module Bar def initialize(b) puts
class ClassName(object): def __init__(self, foo, bar): self.foo = foo # read-write property self.bar =
Suppose we have the following class hierarchy: class ClassA: @property def foo(self): return hello
I find the following example mildly surprising: >>> class Foo: def blah(self): pass >>>
Suppose I have this class: class MyClass(object): def uiFunc(self, MainWindow): self.attr1 = foo self.attr2
The class class A private def foo puts :foo end public def bar puts

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.