Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Commonmark migration
Source Link

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

##Edit:

Edit:

My directory structure:

root
--example.py
--test
----__init.py__
----Configuration.py

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

##Edit:

My directory structure:

root
--example.py
--test
----__init.py__
----Configuration.py

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

Edit:

My directory structure:

root
--example.py
--test
----__init.py__
----Configuration.py
added 127 characters in body
Source Link
batman
  • 4.9k
  • 9
  • 42
  • 49

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

##Edit:

My directory structure:

root
--example.py
--test
----__init.py__
----Configuration.py

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

##Edit:

My directory structure:

root
--example.py
--test
----__init.py__
----Configuration.py
Source Link
batman
  • 4.9k
  • 9
  • 42
  • 49

I'm getting AttributeError when I call a method in other class

I'm very new to Python and I have a code like this:

class Configuration:
 @staticmethod
 def test():
 return "Hello World"

When I call the method test from other python code like this:

import test
test.Configuration.test()

I get an error like this:

Traceback (most recent call last):
 File "example.py", line 3, in <module>
 test.Configuration.test()
AttributeError: 'module' object has no attribute 'test'

where I'm making the mistake?

lang-py

AltStyle によって変換されたページ (->オリジナル) /