This should work (untested since I do not have a pdb file to test). I'm using Generators here:
# first create a generator that parses your structure, one residue at time
def createDesiredList(structure, desired_atoms):
residues = structure.get_residues()
for residue in residues:
return_list = []
for atom_id in desired_atoms:
return_list.append((residue[atom_id].get_coord(), residue))
yield return_list
# then I copy and paste your code ....
pdb = "1dly.pdb"
name = pdb[:3]
from Bio import PDB
from ast import literal_eval
p = PDB.PDBParser()
s = p.get_structure(name, pdb)
# then I decide which atoms I desire from every residue...
wish_list = ['N', 'CA', 'C', 'CB']
# and finally I run my generator, putting the results in a list.
your_coords_list = [x for x in createDesiredList(s, wish_list)]