In [1]: import pytraj as pt
In [2]: traj = pt.load_sample_data('tz2')[:3]
In [3]: traj
Out[3]:
pytraj.Trajectory, 3 frames:
Size: 0.000355 (GB)
<Topology: 5293 atoms, 1704 residues, 1692 mols, PBC with box type = ortho>
In [4]: a, b, c = traj[0], traj[1], traj[2]
In [5]: a, b, c
Out[5]: (<Frame with 5293 atoms>, <Frame with 5293 atoms>, <Frame with 5293 atoms>)
For new users, it’s confusing when you see f(*args, **kwd)
. This is Python sytax to
unpack list/tuple and dictionary respectively
In [6]: def f(x, y, z=0, a=100):
...: print('x = {}'.format(x))
...: print('y = {}'.format(y))
...: print('z = {}'.format(z))
...: print('a = {}'.format(a))
...:
In [7]: my_list = [4, 6]
In [8]: my_dict = {'z': 8, 'a': 9}
# call your function by unpacking list and dictionary
In [9]: f(*my_list, **my_dict)
x = 4
y = 6
z = 8
a = 9
# which is equal to
In [10]: f(4, 6, z=8, a=9)