I just wanna know about os.path module..

James fphsml at gmail.com
Sun Jul 17 05:24:03 EDT 2005



kimes wrote:
> I've just started digging into how python works..
> I found that other mudules are clearly declared like one file per a
> module..
>
> But the only os.path doesn't have their own file..
> ye I know is has actually depending on os like in my case posixpath..
>
> What I'd love to know is..
> when I call import os.path..
> how happened under the hood?
>
> I'm currently using python 2.4 in linux machine..
> I'd appreciate it

See line 5 of os.py (comment)
  - os.path is one of the modules posixpath, ntpath, or macpath
It says it sets os.path depending on the platform

and does so in line 132
sys.modules['os.path'] = path

In your case, os.path should be implemented in posixpath.py
See line 48 to see where it came from

In short, "use the source, Luke" :-)
especially when Python is exceptionally readable.




More information about the Python-list mailing list