On Sat, Oct 31, 2009 at 14:48 -0500, Peng Yu wrote: > On Sat, Oct 31, 2009 at 1:46 PM, Terry Reedy <tjre...@udel.edu> wrote: > > Peng Yu wrote: [ snip ]
> I find the following two files that define realpath. But I don't find > 'realpath' in os.py. I looked at 'os.py'. But I don't understand how > the function realpath is introduced in the name space in os.path. > Would you please let me know? > gfind . ! -path '*backup*' -name "*.py" -type f -exec grep -n "def > realpath" {} \; -printf %p\\n\\n > 193:def realpath(path): > ./macpath.py > > 345:def realpath(filename): > ./posixpath.py The os module needs to support different platforms. The os.path module is actually one of the platform specific ones (ntpath, posixpath, ...) that are imported 'as path' depending on the platform the code is executed. Have a look at the source code of the os module: --- os.py - Python 2.6.3 --- ... f 'posix' in _names: ... import posixpath as path elif 'nt' in _names: ... import ntpath as path import nt __all__.extend(_get_exports_list(nt)) del nt ... else: raise ImportError, 'no os specific module found' sys.modules['os.path'] = path --- snip --- If you really want to understand how a module is working then have a look at its source code. Python is open source --> Use that privilige! kind regards Wolodja Wentland
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list