Chris Rebert wrote:

> The next closest thing would probably be the Python 
> Cookbook:http://code.activestate.com/recipes/langs/python/

One thing I really like about ... my hacked version of path.py ... is
path.cd( lambda: ... ). It works great inside fabfile.py to
temporarily switch to a different folder:

sample_project = path('sample_project').abspath()

def run():
    sample_project.cd( lambda:
        _sh('python manage.py runserver 0.0.0.0:8000 --
settings=test_settings') )

After the lambda runs, we exception-safely return to the home folder.

(BTW I'm aware that a fabfile.py command with only one statement will
return to its shell and remain in the correct folder. It's just ...
the thought!)

This be .cd():

class path:

    def cd(self, block=None):
        previous = path(os.path.curdir).abspath()
        self.chdir()

        if block:
            try:      block()
            finally:  previous.chdir()

That's based on Jason Orendoff's work at 
http://www.jorendorff.com/articles/python/path

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to