Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 14th, 2012, 05:47 PM
muzauk muzauk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 4 muzauk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 32 sec
Reputation Power: 0
Reading builtin python modules

I dont understand how to read the code in the builtin python modules. I know how to find out whats in a module for example,

import os;

dir(os)
But when I try to look for example for the function listdir I cannot find a def listdir to read what it actually does.

Reply With Quote
  #2  
Old December 14th, 2012, 06:37 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 42 sec
Reputation Power: 383
The source for os.listdir is almost certainly written in c. Python would load it from a shared object or dynamic link library. If you really want it, download the python source and hunt for it.

...Trying my advice...
I think it starts with this line in file posixmodule.c.

posix_listdir(PyObject *self, PyObject *args, PyObject *kwargs)
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old December 14th, 2012, 08:00 PM
muzauk muzauk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 4 muzauk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 32 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
The source for os.listdir is almost certainly written in c. Python would load it from a shared object or dynamic link library. If you really want it, download the python source and hunt for it.

...Trying my advice...
I think it starts with this line in file posixmodule.c.

posix_listdir(PyObject *self, PyObject *args, PyObject *kwargs)


Ok thank you for the response but I still dont quite follow. OS.py is written in python right? so when i import os im importing os.py, why then can i not find the functions listed inside os.py that i can see when i do a dir(os)

Reply With Quote
  #4  
Old December 14th, 2012, 08:10 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 42 sec
Reputation Power: 383
An os.py on my system:
/usr/lib/python2.7/os.py


Read this manual.

Reply With Quote
  #5  
Old December 14th, 2012, 09:12 PM
muzauk muzauk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 4 muzauk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 32 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
An os.py on my system:
/usr/lib/python2.7/os.py


manual.


That goes a little over my head at this stage in my learning python. Are you basically saying that the functions arent in os.py but os.py loads some c code that includes the os.blar functions?

Reply With Quote
  #6  
Old December 14th, 2012, 09:15 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 42 sec
Reputation Power: 383
Yes.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Reading builtin python modules

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap