Please explain what you mean by import every time.
You need to reconsider the use of class attributes before you know exactly what they are doing, especially if you use mutable types like lists. Consider this:
>>> class Borg(object): ... alist = list() ... >>> a = Borg() >>> b = Borg() >>> a.alist.append('qwerty') >>> a.alist ['qwerty'] >>> b.alist ['qwerty'] >>>
Not what you wanted? Use the regular Python idiom to customize what you need in the __init__ class method:
>>> class Normal(object): ... def __init__(self): ... self.alist = list() ... >>> x = Normal() >>> y = Normal() >>> x.alist.append('frobozz') >>> x.alist ['frobozz'] >>> y.alist [] >>>
source share