On Sun, Nov 2, 2008 at 4:15 PM, Ronan Paixão <[EMAIL PROTECTED]> wrote: > > don't know if this is "the right"(tm) way to do it, but it seems more > pythonic: > > import os > [p for p in os.environ['PATH'].split(':') if os.path.exists('%s/%s' % > (p,'phc'))] > > which should return a list with the paths in which the file 'phc' > exists, or an empty list if it doesn't > > Ronan Paixão
That is unfortunately not equivalent to the unix which command. For example, if the file phc appears anywhere in the path it will get included. The which command instead will tell you whether or not there is an *executable* called phc that is in the path. So that's a subtle difference. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---