0

I have 2 modules.

  1. runtest.py, where main is defined and

    if name == "main":
    
        # general purpose library
        na = nalib.NALib()
        ...
        classnames = na.get_classnames(classes)
    

    Hence I'm getting all the classes preset in the module in 'classnames'

  2. libna.py

    This is where NALib class and get_classnames(self, classes) is defined.

Now to manipulate with classes further, I need to have attributes of classnames (present in runtest.py)

I checked with getattr syntax that we need object and name for the same. Hence I'm not sure what is the exact way to print out attributes of classnames using getattr?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
NikAsawadekar
  • 57
  • 1
  • 5
  • I think some underscores and spaces are missing because I copied it directly from notepad. Sorry for that.. but the code is working except the getattr thing. – NikAsawadekar Aug 12 '14 at 15:46
  • did you consider using inspect? it allows you to get all classes from module, and the all attributes of those classes and so on so forth take a look at: https://docs.python.org/2/library/inspect.html – user3012759 Aug 12 '14 at 15:53
  • @user3012759 Yeah got it. I tried it with classname directly instead of object and found it working. variable = getattr(classname, variabletotest) – NikAsawadekar Aug 12 '14 at 21:12

0 Answers0