Q:

Apply function to loop item

Consider the code below:
f = open('file.txt')

for l in f:
    k = l.strip() # Remove the newline character. 
    print(k)

f.close()

I'd like to automatically remove the newline.  I know I could do:
for k in [l.strip() for l in f]:
    print(k)

But this requires looping the length of f twice (and loading the whole thing into memory).  I'm wondering if there is something even more Pythonic like:
for lambda l: l.strip() in f:
    print(l)

or maybe just:
for l.strip() in f:
    print(l)

Of course, neither of these work.  To see how this could be applied elsewhere, here's an example with nested lists:
d =  [['hi'], ['hello'], ['howdy']]
for item in d:
    item = item[0] # Get the nested item. 
    if item == 'hello':
         print(item)

A:

You can use a generator expression:
for k in (l.strip() for l in f):
    print(k)

This is very similar to the list comprehension, except that it produces items lazily (one-by-one) instead of collecting them all into a list at once.   So, we only loop the length of f a single time and also avoid dumping everything into memory all at one time. 

A:

Welcome to the world of Python iterators :)
You have the right idea with the list comprehensions, except you want it to lazy-load and not build up the entire list in memory first (which may even be untenable for very large files): use generator expressions instead, which have the same syntax except the square brackets are replaced by parentheses (which you can omit if it is the sole argument to a function):
with open(filename) as f:
    for l in (l.strip() for l in f.readlines()):
        print(l)

Source: Read more about them in the relevant Python Enhancement Proposal and the official docs. 

An alternative, functional way of doing it with a syntax similar to LISP's is using map which applies a function to each element of an iterator — it doesn't have to be a sequence, and assuming you're on Python this will involve looping through all the lines just once:
for l in map(lambda l: l.strip (), f):
    print(l)

Also, f.readlines() would probably be clearer than just looping over f, and a with statement is more Pythonic than calling f.close() yourself.