For loop that iterates through files and iteratively appends lists storing values from the read file How can I fasten this code, that reads a text file sequentially and appends a list? fp and fp_2 reads two different files from the same sub-sirectory here

import os
import glob
from IPython import embed
import numpy as np


dirs = os.listdir("/home/Set/")

poseList = [] #Store poses for all files
featuresList = [] # Store features

def data():
    for dir_name in dirs: 
        fp = '/home/Set/left'
        fp_2 =  '/home/Set/fc/fc2_0.npy'
        if os.path.exists(fp) and os.path.exists(fp_2):
            files = glob.glob(fp+"/*.txt")
            curr_pose = []  #Store curr pose
            for f in files:
                with open(f) as pose:
                    pl = pose.readlines()
                    pl = [p.strip() for p in pl] 
                    pl = map(float, pl)  # str -&gt;float
                    curr_pose.append((pl))
            poseList.append(curr_pose)   #append to main list 
            featuresList.append(np.load(fp_2))
        print "Not available", dir_name

data()    
embed()
Variable naming

Your variable's names do not convey their purpose and are even misleading.
E.g. fp and fp_2 suggest file pointers, but are actually strings.
Notwithstanding, for a better reference, I will use your variable names below.

You should also implement PEP8 (poseList vs. pose_list etc.).

Recurring declaration

You keep redefining the same constants fp and fp_2 in a loop:

for dir_name in dirs: 
    fp = '/home/Set/left'
    fp_2 =  '/home/Set/fc/fc2_0.npy'


Better declare them beforehand:

fp = '/home/Set/left'
fp_2 =  '/home/Set/fc/fc2_0.npy'

for dir_name in dirs:


Avoiding race conditions

By checking for existing files and folders using

if os.path.exists(fp) and os.path.exists(fp_2):


you've created yourself a race condition.
It is better to just try to open the file and handle the respective exception raised if something goes wrong.

Joining paths

Your path concatenation

fp+"/*.txt"


might work for you.
But there is os.path.join to do this safely and get a sanitized path:

os.path.join(fp, "*.txt")  # Leading "/" removed!


Just for the record: In Python 3 (which you are not using assuming from your print statement) you can use pathlib.Path to handle your paths:

fp = Path('/home/Set/left')
…
str(fp.joinpath('*.txt'))


Reading lines

Files are iterable, so you can get a file's lines more easily:

for f in files:
    with open(f) as pose:
        pl = [line.strip() for line in pose] 
        …