summary refs log blame commit diff stats
path: root/doc/pydoc/os.path.html
blob: f62cddae14c462b0919617f27765147f81b15813 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
 

                                                              






                                                                                                                   
                                                                                                                                                                                                                                                         



















                                                                                                                                 
                                                                        
































                                                                                                                                                                                                                          
                                                                                                                                                                                                   










                                                                                                                                                                                                               












                                                                                                                                                       






                                                                                               
                                                                                                                                                                                                                                                                                









                                                                     
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module posixpath</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>posixpath</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/lib/python2.6/posixpath.py">/usr/lib/python2.6/posixpath.py</a><br><a href="http://docs.python.org/library/posixpath">Module Docs</a></font></td></tr></table>
    <p><tt>Common&nbsp;operations&nbsp;on&nbsp;Posix&nbsp;pathnames.<br>
&nbsp;<br>
Instead&nbsp;of&nbsp;importing&nbsp;this&nbsp;module&nbsp;directly,&nbsp;import&nbsp;os&nbsp;and&nbsp;refer&nbsp;to<br>
this&nbsp;module&nbsp;as&nbsp;os.path.&nbsp;&nbsp;The&nbsp;"os.path"&nbsp;name&nbsp;is&nbsp;an&nbsp;alias&nbsp;for&nbsp;this<br>
module&nbsp;on&nbsp;Posix&nbsp;systems;&nbsp;on&nbsp;other&nbsp;systems&nbsp;(e.g.&nbsp;Mac,&nbsp;Windows),<br>
os.path&nbsp;provides&nbsp;the&nbsp;same&nbsp;operations&nbsp;in&nbsp;a&nbsp;manner&nbsp;specific&nbsp;to&nbsp;that<br>
platform,&nbsp;and&nbsp;is&nbsp;an&nbsp;alias&nbsp;to&nbsp;another&nbsp;module&nbsp;(e.g.&nbsp;macpath,&nbsp;ntpath).<br>
&nbsp;<br>
Some&nbsp;of&nbsp;this&nbsp;can&nbsp;actually&nbsp;be&nbsp;useful&nbsp;on&nbsp;non-Posix&nbsp;systems&nbsp;too,&nbsp;e.g.<br>
for&nbsp;manipulation&nbsp;of&nbsp;the&nbsp;pathname&nbsp;component&nbsp;of&nbsp;URLs.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="genericpath.html">genericpath</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="stat.html">stat</a><br>
</td><td width="25%" valign=top><a href="warnings.html">warnings</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-abspath"><strong>abspath</strong></a>(path)</dt><dd><tt>Return&nbsp;an&nbsp;absolute&nbsp;path.</tt></dd></dl>
 <dl><dt><a name="-basename"><strong>basename</strong></a>(p)</dt><dd><tt>Returns&nbsp;the&nbsp;final&nbsp;component&nbsp;of&nbsp;a&nbsp;pathname</tt></dd></dl>
 <dl><dt><a name="-commonprefix"><strong>commonprefix</strong></a>(m)</dt><dd><tt>Given&nbsp;a&nbsp;list&nbsp;of&nbsp;pathnames,&nbsp;returns&nbsp;the&nbsp;longest&nbsp;common&nbsp;leading&nbsp;component</tt></dd></dl>
 <dl><dt><a name="-dirname"><strong>dirname</strong></a>(p)</dt><dd><tt>Returns&nbsp;the&nbsp;directory&nbsp;component&nbsp;of&nbsp;a&nbsp;pathname</tt></dd></dl>
 <dl><dt><a name="-exists"><strong>exists</strong></a>(path)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;exists.&nbsp;&nbsp;Returns&nbsp;False&nbsp;for&nbsp;broken&nbsp;symbolic&nbsp;links</tt></dd></dl>
 <dl><dt><a name="-expanduser"><strong>expanduser</strong></a>(path)</dt><dd><tt>Expand&nbsp;~&nbsp;and&nbsp;~user&nbsp;constructions.&nbsp;&nbsp;If&nbsp;user&nbsp;or&nbsp;$HOME&nbsp;is&nbsp;unknown,<br>
do&nbsp;nothing.</tt></dd></dl>
 <dl><dt><a name="-expandvars"><strong>expandvars</strong></a>(path)</dt><dd><tt>Expand&nbsp;shell&nbsp;variables&nbsp;of&nbsp;form&nbsp;$var&nbsp;and&nbsp;${var}.&nbsp;&nbsp;Unknown&nbsp;variables<br>
are&nbsp;left&nbsp;unchanged.</tt></dd></dl>
 <dl><dt><a name="-getatime"><strong>getatime</strong></a>(filename)</dt><dd><tt>Return&nbsp;the&nbsp;last&nbsp;access&nbsp;time&nbsp;of&nbsp;a&nbsp;file,&nbsp;reported&nbsp;by&nbsp;os.stat().</tt></dd></dl>
 <dl><dt><a name="-getctime"><strong>getctime</strong></a>(filename)</dt><dd><tt>Return&nbsp;the&nbsp;metadata&nbsp;change&nbsp;time&nbsp;of&nbsp;a&nbsp;file,&nbsp;reported&nbsp;by&nbsp;os.stat().</tt></dd></dl>
 <dl><dt><a name="-getmtime"><strong>getmtime</strong></a>(filename)</dt><dd><tt>Return&nbsp;the&nbsp;last&nbsp;modification&nbsp;time&nbsp;of&nbsp;a&nbsp;file,&nbsp;reported&nbsp;by&nbsp;os.stat().</tt></dd></dl>
 <dl><dt><a name="-getsize"><strong>getsize</strong></a>(filename)</dt><dd><tt>Return&nbsp;the&nbsp;size&nbsp;of&nbsp;a&nbsp;file,&nbsp;reported&nbsp;by&nbsp;os.stat().</tt></dd></dl>
 <dl><dt><a name="-isabs"><strong>isabs</strong></a>(s)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;is&nbsp;absolute</tt></dd></dl>
 <dl><dt><a name="-isdir"><strong>isdir</strong></a>(s)</dt><dd><tt>Return&nbsp;true&nbsp;if&nbsp;the&nbsp;pathname&nbsp;refers&nbsp;to&nbsp;an&nbsp;existing&nbsp;directory.</tt></dd></dl>
 <dl><dt><a name="-isfile"><strong>isfile</strong></a>(path)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;is&nbsp;a&nbsp;regular&nbsp;file</tt></dd></dl>
 <dl><dt><a name="-islink"><strong>islink</strong></a>(path)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;is&nbsp;a&nbsp;symbolic&nbsp;link</tt></dd></dl>
 <dl><dt><a name="-ismount"><strong>ismount</strong></a>(path)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;is&nbsp;a&nbsp;mount&nbsp;point</tt></dd></dl>
 <dl><dt><a name="-join"><strong>join</strong></a>(a, *p)</dt><dd><tt>Join&nbsp;two&nbsp;or&nbsp;more&nbsp;pathname&nbsp;components,&nbsp;inserting&nbsp;'/'&nbsp;as&nbsp;needed.<br>
If&nbsp;any&nbsp;component&nbsp;is&nbsp;an&nbsp;absolute&nbsp;path,&nbsp;all&nbsp;previous&nbsp;path&nbsp;components<br>
will&nbsp;be&nbsp;discarded.</tt></dd></dl>
 <dl><dt><a name="-lexists"><strong>lexists</strong></a>(path)</dt><dd><tt>Test&nbsp;whether&nbsp;a&nbsp;path&nbsp;exists.&nbsp;&nbsp;Returns&nbsp;True&nbsp;for&nbsp;broken&nbsp;symbolic&nbsp;links</tt></dd></dl>
 <dl><dt><a name="-normcase"><strong>normcase</strong></a>(s)</dt><dd><tt>Normalize&nbsp;case&nbsp;of&nbsp;pathname.&nbsp;&nbsp;Has&nbsp;no&nbsp;effect&nbsp;under&nbsp;Posix</tt></dd></dl>
 <dl><dt><a name="-normpath"><strong>normpath</strong></a>(path)</dt><dd><tt>Normalize&nbsp;path,&nbsp;eliminating&nbsp;double&nbsp;slashes,&nbsp;etc.</tt></dd></dl>
 <dl><dt><a name="-realpath"><strong>realpath</strong></a>(filename)</dt><dd><tt>Return&nbsp;the&nbsp;canonical&nbsp;path&nbsp;of&nbsp;the&nbsp;specified&nbsp;filename,&nbsp;eliminating&nbsp;any<br>
symbolic&nbsp;links&nbsp;encountered&nbsp;in&nbsp;the&nbsp;path.</tt></dd></dl>
 <dl><dt><a name="-relpath"><strong>relpath</strong></a>(path, start<font color="#909090">='.'</font>)</dt><dd><tt>Return&nbsp;a&nbsp;relative&nbsp;version&nbsp;of&nbsp;a&nbsp;path</tt></dd></dl>
 <dl><dt><a name="-samefile"><strong>samefile</strong></a>(f1, f2)</dt><dd><tt>Test&nbsp;whether&nbsp;two&nbsp;pathnames&nbsp;reference&nbsp;the&nbsp;same&nbsp;actual&nbsp;file</tt></dd></dl>
 <dl><dt><a name="-sameopenfile"><strong>sameopenfile</strong></a>(fp1, fp2)</dt><dd><tt>Test&nbsp;whether&nbsp;two&nbsp;open&nbsp;file&nbsp;objects&nbsp;reference&nbsp;the&nbsp;same&nbsp;file</tt></dd></dl>
 <dl><dt><a name="-samestat"><strong>samestat</strong></a>(s1, s2)</dt><dd><tt>Test&nbsp;whether&nbsp;two&nbsp;stat&nbsp;buffers&nbsp;reference&nbsp;the&nbsp;same&nbsp;file</tt></dd></dl>
 <dl><dt><a name="-split"><strong>split</strong></a>(p)</dt><dd><tt>Split&nbsp;a&nbsp;pathname.&nbsp;&nbsp;Returns&nbsp;tuple&nbsp;"(head,&nbsp;tail)"&nbsp;where&nbsp;"tail"&nbsp;is<br>
everything&nbsp;after&nbsp;the&nbsp;final&nbsp;slash.&nbsp;&nbsp;Either&nbsp;part&nbsp;may&nbsp;be&nbsp;empty.</tt></dd></dl>
 <dl><dt><a name="-splitdrive"><strong>splitdrive</strong></a>(p)</dt><dd><tt>Split&nbsp;a&nbsp;pathname&nbsp;into&nbsp;drive&nbsp;and&nbsp;path.&nbsp;On&nbsp;Posix,&nbsp;drive&nbsp;is&nbsp;always<br>
empty.</tt></dd></dl>
 <dl><dt><a name="-splitext"><strong>splitext</strong></a>(p)</dt><dd><tt>Split&nbsp;the&nbsp;extension&nbsp;from&nbsp;a&nbsp;pathname.<br>
&nbsp;<br>
Extension&nbsp;is&nbsp;everything&nbsp;from&nbsp;the&nbsp;last&nbsp;dot&nbsp;to&nbsp;the&nbsp;end,&nbsp;ignoring<br>
leading&nbsp;dots.&nbsp;&nbsp;Returns&nbsp;"(root,&nbsp;ext)";&nbsp;ext&nbsp;may&nbsp;be&nbsp;empty.</tt></dd></dl>
 <dl><dt><a name="-walk"><strong>walk</strong></a>(top, func, arg)</dt><dd><tt>Directory&nbsp;tree&nbsp;walk&nbsp;with&nbsp;callback&nbsp;function.<br>
&nbsp;<br>
For&nbsp;each&nbsp;directory&nbsp;in&nbsp;the&nbsp;directory&nbsp;tree&nbsp;rooted&nbsp;at&nbsp;top&nbsp;(including&nbsp;top<br>
itself,&nbsp;but&nbsp;excluding&nbsp;'.'&nbsp;and&nbsp;'..'),&nbsp;call&nbsp;func(arg,&nbsp;dirname,&nbsp;fnames).<br>
dirname&nbsp;is&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;directory,&nbsp;and&nbsp;fnames&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;names&nbsp;of<br>
the&nbsp;files&nbsp;and&nbsp;subdirectories&nbsp;in&nbsp;dirname&nbsp;(excluding&nbsp;'.'&nbsp;and&nbsp;'..').&nbsp;&nbsp;func<br>
may&nbsp;modify&nbsp;the&nbsp;fnames&nbsp;list&nbsp;in-place&nbsp;(e.g.&nbsp;via&nbsp;del&nbsp;or&nbsp;slice&nbsp;assignment),<br>
and&nbsp;walk&nbsp;will&nbsp;only&nbsp;recurse&nbsp;into&nbsp;the&nbsp;subdirectories&nbsp;whose&nbsp;names&nbsp;remain&nbsp;in<br>
fnames;&nbsp;this&nbsp;can&nbsp;be&nbsp;used&nbsp;to&nbsp;implement&nbsp;a&nbsp;filter,&nbsp;or&nbsp;to&nbsp;impose&nbsp;a&nbsp;specific<br>
order&nbsp;of&nbsp;visiting.&nbsp;&nbsp;No&nbsp;semantics&nbsp;are&nbsp;defined&nbsp;for,&nbsp;or&nbsp;required&nbsp;of,&nbsp;arg,<br>
beyond&nbsp;that&nbsp;arg&nbsp;is&nbsp;always&nbsp;passed&nbsp;to&nbsp;func.&nbsp;&nbsp;It&nbsp;can&nbsp;be&nbsp;used,&nbsp;e.g.,&nbsp;to&nbsp;pass<br>
a&nbsp;filename&nbsp;pattern,&nbsp;or&nbsp;a&nbsp;mutable&nbsp;object&nbsp;designed&nbsp;to&nbsp;accumulate<br>
statistics.&nbsp;&nbsp;Passing&nbsp;None&nbsp;for&nbsp;arg&nbsp;is&nbsp;common.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ['normcase', 'isabs', 'join', 'splitdrive', 'split', 'splitext', 'basename', 'dirname', 'commonprefix', 'getsize', 'getmtime', 'getatime', 'getctime', 'islink', 'exists', 'lexists', 'isdir', 'isfile', 'ismount', 'walk', ...]<br>
<strong>altsep</strong> = None<br>
<strong>curdir</strong> = '.'<br>
<strong>defpath</strong> = ':/bin:/usr/bin'<br>
<strong>devnull</strong> = '/dev/null'<br>
<strong>extsep</strong> = '.'<br>
<strong>pardir</strong> = '..'<br>
<strong>pathsep</strong> = ':'<br>
<strong>sep</strong> = '/'<br>
<strong>supports_unicode_filenames</strong> = False</td></tr></table>
</body></html>