Hi 
I have a class which represents a sort of DOM of a binary data file. Most of 
the attributes of each class instance depend upon the content and content 
structure of the file.

1) How can i tell Astroid that an Attribute represented by an Attribute node is 
existent. Or what kind of node (nodes) must the inference interator return in 
order that astroid or pylint respectiv concludes that the attribute is existing 
eventhough it could not infer it from the scoure code.

2) What is in addition needed in case the value of the attribute would be 
another instance of the DOM tree node class

Are there any extensively document examples or howtos demonstrating how to do 
this

For Example:

```
class Node(object):
     def __init__(self) :
          self.children = {}

    
    def add_child(self,name,child):
          self.children[name] = child
          if getattr(self.__class__,name,None) is None:
              def get_child(self):
                    return self.children[name]
              setattr(self.__class__,name,property(get_child))


def main():
   data_node = Node()
   sub_node = Node()
   data_node.add_child("first",sub_node)
   data_node.add_child("second",[1,2,3])
   print(data_node.first)
   data_node.first.add_child("first_first","miau")
   print(data_node.first.first_first)

if __name__ == "__main__":
    main()
```

How to tell astroid that first is a valid attribute and how to tell that first 
first of first is also a valid attribute.
_______________________________________________
code-quality mailing list -- code-quality@python.org
To unsubscribe send an email to code-quality-le...@python.org
https://mail.python.org/mailman3/lists/code-quality.python.org/

Reply via email to