0
votes

I have two classes in the same folder; filename

  • Filename: twisted, class name : Root,method :def render_GET(self, request):
  • Filename: ladpConnector, class name:MyClass, method : getMachines(self)

I want to call getMachines from the first file, inside Root class.

I tried following options;

  • MyClass().getMachines()

from ldapConnector import Myclass

MyClass().getMachines()

All gives issues, undefined method/undefined variable class Myclass etc..

What is teh right way to call that method?

2
In from ldapConnector import Myclass class name not is same case(MyClass) - SatanDmytro
@SatanDmytro it is right ..here it is typo..Thanks there was another spelling mistake..It works. - Ratha

2 Answers

1
votes

I'm not sure what you are asking, but you need to import that class in the file that has the Root class:

# twisted.py file
from ldapConnector import MyClass

class Root():
    def __init__(self):
        MyClass().getConnections()
1
votes

To access files within the same module you need to do relative imports: from .ldapConnector import MyClass should work.