MATLAB has a very convenient syntax for getting half of a list:
The syntax I know for python to do this is
This is fine in this case, because
len(x) is easy to write. But this syntax becomes more than a pain when the name of the list is long (as they sometimes need to be), and even more so when there is a list of similar long names.
I know this is a real shot in the dark, but does python have any syntax option like MATLAB's?
There is no specialized syntax. If you need to do it a lot, write a function:
def half_list(l): return l[:len(l)/2]
No, lists in python don't have the concept
end( a somewhat similar concept is the index
An easy (but not recommended) solution to your problem is:
l = longnamelist l[:len(l)/2]
or to copy/paste the long name... (some editors have a shortcut for copying a word, this makes copy/paste of a long name very easy.)