Comment 1 for bug 1513067

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

This is an example:

[gcb@localhost tests]$ cat test_reflect.py

import pdb
from oslo_utils import reflection

class ClassA(object):

    def __init__(self):

        class ClassB(object):
            pass
        self.api = ClassB()

    def test_get_nested_class_name(self):
        class_name = reflection.get_class_name(self.api, fully_qualified=False)
        print(class_name)
        class_name = reflection.get_class_name(self.api, fully_qualified=True)
        print(class_name)

a = ClassA()
a.test_get_nested_class_name()

[gcb@localhost tests]$ python test_reflect.py
ClassB
__main__.ClassB

[gcb@localhost tests]$ python3 test_reflect.py
ClassA.__init__.<locals>.ClassB
__main__.ClassA.__init__.<locals>.ClassB