This is terribly ugly:
psData = []
nsData = []
msData = []
ckData = []
mAData = []
RData = []
pData = []
Is there a way to declare these variables on a single line?
This is terribly ugly:
psData = []
nsData = []
msData = []
ckData = []
mAData = []
RData = []
pData = []
Is there a way to declare these variables on a single line?
alist, blist, clist, dlist, elist = ([] for i in range(5))
the downside is, you need to count the number of names on the left of =
and have exactly the same number of empty lists (e.g. via the range
call, or more explicitly) on the right hand
side. The main thing is, don't use something like
alist, blist, clist, dlist, elist = [[]] * 5
or
alist = blist = clist = dlist = elist = []
which would make all names refer to the same empty list!
Depending on your needs, you could consider using a defaultdict with a list factory. Something like:
my_lists = collections.defaultdict(list)
and then you can directly append to my_lists["psData"] and so on. This is the relevant doc page: http://docs.python.org/library/collections.html#collections.defaultdict