On Jun 7, 1:19 pm, dmitrey <[EMAIL PROTECTED]> wrote: > On Jun 7, 10:18 am, Gerard Flanagan <[EMAIL PROTECTED]> wrote:> On Jun 7, > 8:39 am, dmitrey <[EMAIL PROTECTED]> wrote: > > Thank you. > And what is the simplest way (without split/join, if exist) to obtain > name of directory parent to directory my_directory_name? > > Thx, D. >
>>> os.path.join(os.pardir, os.path.dirname('/a/b/c/d/e/f.log')) '/a/b/c/d/e' >>> os.path.join(os.pardir, os.path.dirname(_)) '/a/b/c/d' >>> os.path.join(os.pardir, os.path.dirname(_)) '/a/b/c' >>> os.path.join(os.pardir, os.path.dirname(_)) '/a/b' >>> os.path.join(os.pardir, os.path.dirname(_)) '/a' >>> os.path.join(os.pardir, os.path.dirname(_)) '/' >>> os.path.join(os.pardir, os.path.dirname(_)) '/' (When using the interactive interpreter, an underscore '_' means 'the previous result') HTH Gerard -- http://mail.python.org/mailman/listinfo/python-list