Get Parent path value (bad design) Help

Miki Tebeka miki.tebeka at zoran.com
Mon Aug 30 17:19:56 EDT 2004


Hello Moiz,

> What I am trying to do is write some generic code where I can get the
> path of the parent directory. for example if current working directory is
> 'Z:\\dirA\\Parent\\Child'
> 
> I want to get a string which up like 'Z:\\dirA\\Parent'
> Then I do a sys.path.append('Z:\\dirA\\Parent')
Just use os.path.dirname

>>> from os.path import dirname
>>> dirname(r"z:\dira\parent\child")
'z:\\dira\\parent'
>>>

HTH.
--
------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys



More information about the Python-list mailing list