我正在使用eclips for python,並且我正面臨一個問題。我有很多具有許多屬性的類,並且需要我的一個聲明類中的對象列表。問題是:當我訪問列表中的任何項目時,IDE不知道它的類型,因爲在python中我們沒有聲明變量的類型,所以沒有自動完成,我必須去類複製屬性名稱。 爲了讓想法更加清晰:Python強類型列表
class AutomataBranch(object):
def __init__(selfparams):
self.Name="";
self.nodes=[];
class LanguageAutomata(object):
def __init__(selfparams):
self.cfgAutomata=[];#This has AutomaBranch Type
現在在LanguageAutomata類中的任何方法,如果我寫道: cfgAutomata
。然後它不會給我名稱屬性 有沒有解決方案?
你在使用PyDev嗎? http://pydev.sourceforge.net/ – mcandre 2009-08-17 14:57:31
self.cfgAutomata有一個列表類型。你是否真的試圖獲得self.cfgAutomata類型[]? –
2009-08-17 15:15:56
這裏有一個錯字,對不對?在_ \ _ _ _ _ _ _ _ _ _ _ _ _ _ _中初始化一個逗號def __init __(self,params): – hughdbrown 2009-08-17 15:20:10