A cleaner, though not shorter, rewriting could be:
from itertools import chain
def ancestors(path):
while True:
yield path
parent = os.path.dirname(path)
if parent == path:
break
path = parent
for dir in chain([os.environ['HOME']],
Hi all,
I need a cleaner ( and shorter ) way to to look in my home directory or
any directory for a directory called modules. This is what I currently
have - but it is really ugly. Some a few of you experts point me to a
cleaner more pythonic approach?
mod = 0
if os.path.exists( o