0

I'm trying to call a static method of a class from a different module and getting:

AttributeError: ClassObject instance has no attribute 'foo1'

Things are structures like this:
a.py file content:

class Conf():
    def __init__(self,......):
       .
       .
       .
    @staticmethod
    def foo1():
       .
       .
       .

b.py file content:

from a import Conf
Conf.foo1()

What am I doing wrong?

4
  • It's the same thing, I wanted to write here the minimal code necessary to demonstrate it Commented Nov 29, 2016 at 8:55
  • I'm not sure this is the cause of your problem, but since this question is tagged with Python 2, try to inherit from object: class Conf(object): Commented Nov 29, 2016 at 8:55
  • Well I will try now Commented Nov 29, 2016 at 8:57
  • 1
    I typed your exact conf class definition, it works Commented Nov 29, 2016 at 8:57

1 Answer 1

1

You are calling your method in the good way, so maybe you are not importing the module.

Check which file is loaded as a.py in b.py:

import a
print a.__file__

This will print which file is loaded.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.