#StackBounty: #python #autocomplete #attributes Is it possible to have Python IDEs offer autocompletion for dynamically generated class…

Bounty: 200

Are there any tricks I can employ to get IDEs to offer code completion for dynamically generated class attributes? For instance


class A:
    
    def __init__(self):
        setattr(self, "a", 5)

This code will set the class attribute of A called a to the value of 5. But IDEs do not know about a and therefore you do not get code completion for it. I’ve read that the __dir__ method can be hooked, but the suggestion made in that answer has not worked for me. Does anybody have any ideas?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.