Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Strongly type lists

I am using eclipse for python and I am facing a problem. I have many classes with many properties and want a list of objects from one of my declared classes. The problem is: When I am accessing any item from the list, the IDE does not know its type because in python we do not declare the variable with type, so there is no auto complete and I have to go to the class to copy the attribute name.

To make idea more clear:

class AutomataBranch(object):
    def __init__(selfparams):
        self.Name="";
        self.nodes=[];

class LanguageAutomata(object):    
    def __init__(selfparams):
        self.cfgAutomata=[];#This has AutomaBranch Type

Now in any method in LanguageAutomata class if I wrote: cfgAutomata. Then it wont give me the Name attribute Is there any solution for that?

like image 431
Hani Avatar asked Dec 17 '22 06:12

Hani


1 Answers

Python is strongly typed and Python lists are too. Your problem come from the fact that Python is dynamically typed. Therefor a var can contain any type, and therefor no IDE can guess what is the type of your parameter, nor give you code completion for the methods.

This is how it is, there is no clean workaround. If it's a problem, then maybe dynamics language is not you predilection tool and you should use something that fit your development style. There are tools for everybody.

like image 67
e-satis Avatar answered Dec 24 '22 15:12

e-satis