Is there something similar in Python that I would use for a container that's like a vector and a list?
Any links would be helpful too.
You can use the inbuilt list - underlying implementation is similar to C++ vector. Although some things differ - for example, you can put objects of different type in one and the same list.
Have a look at Python's datastructures page. Here's a rough translation:
- () => boost::Tuple (with one important distinction, you can't reassign values in a Python tuple)
- [] => std::vector (as the comments have aluded towards, lacks memory characteristics associated with vectors)
- [] => std::list
- {} => tr1::unordered_map or boost::unordered_map (essentially a hash table)
- set() => std::set
Lists are sequences.
see http://docs.python.org/tutorial/datastructures.html
append is like push_back, see the other methods as well.
来源:https://stackoverflow.com/questions/4637095/python-equivalent-for-c-stl-vector-list-containers