How to display name of elements in list?
Magnus Lycka
lycka at carmen.se
Wed Jul 12 09:51:36 EDT 2006
>> My list called "elten" looks like that:
>>
>> [Tensor: id = 1, intensity = 2976.52
>> xx = -1447.32, xy = 52.458, xz = -594.186
>> yy = -1090.54, yz = -0.0158068, zz = -4043.
>> , Tensor: id = 26, intensity = 2896.9
>> ...
>> , Tensor: id = 5, intensity = 2920.5
>> xx = -1534.53, xy = 23.4858, xz = -623.967
>> yy = -1070.47, yz = 99.6301, zz = -3979.87
>> ]
> The list above is not a valid Python list. What is it that you store in that list?
It might well be a normal Python list.
The question is what type the items in the list are...
The result of printing a list L is basically a string you
could make like this:
'[' + ','.join(map(repr,L)) + ']'
It seems the elements in this list appear as something
like this when you apply the repr() function on them:
Tensor: id = 1, intensity = 2976.52
xx = -1447.32, xy = 52.458, xz = -594.186
yy = -1090.54, yz = -0.0158068, zz = -4043.
So, the issue is not how you work with a list,
but how you work with the elements of this type.
To reduce the problem to that, you can assign the
first element in the list to a variable.
elem0 = elten[0]
Then you can inspect that in isolation, without
the confusion of the list.
type(elem0)
dir(elem0)
etc...
More information about the Python-list
mailing list