473,378 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

guide to introspecting python?

What's a good document to read in order to understand some
of python's introspective functions?

I'm trying to recurse through a module and print information
about its contents. dir() does something similar to what
I have in mind, but it's documented to be more for human
interaction than definitive programmatic correctness,
so I'd like to call or look at whatever it's using.

This bit of code never finishes because dir(something)
and dir(something.__call__) return the same thing.

def rdir(item, v=""):
print "%s%s"%(v,item)
for i in dir(item):
rdir(i, v+" ")

import os
rdir(os)
Any help/pointers appreciated!

Thanks,
Mark

PS, you will probably recognize this as my attempt to
generate programatically the module/function/parameter
index I previously asked about...

--
Mark Harrison
Pixar Animation Studios
Jul 18 '05 #1
4 1274
Mark Harrison wrote:
What's a good document to read in order to understand some
of python's introspective functions? .... PS, you will probably recognize this as my attempt to
generate programatically the module/function/parameter
index I previously asked about...


Isn't the "inspect" standard module exactly what you need?
Jul 18 '05 #2

Mark> def rdir(item, v=""):
Mark> print "%s%s"%(v,item)
Mark> for i in dir(item):
Mark> rdir(i, v+" ")

Mark> import os
Mark> rdir(os)

Problem is, dir() is already recursive:
class A: ... def a(self): pass
... class B: ... def b(self): pass
... class C(A,B): pass ... c = C()
dir(c) ['__doc__', '__module__', 'a', 'b'] dir(C)

['__doc__', '__module__', 'a', 'b']

As others have suggested, the inspect module is probably a good place to
start.

Skip
Jul 18 '05 #3
Peter Hansen <pe***@engcorp.com> wrote:
Isn't the "inspect" standard module exactly what you need?


Yes it is... thanks!
Jul 18 '05 #4
I saw that you work for pixar. Do they use python alot? Is it mostly
for making tools for the artists or something else? And one last
question does pixar use their own software for rendering or more
commercial stuff like Maya/3d Studio Max. Sorry for being nosey.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Christian Seberino | last post by:
Linux kernel style guide, Guido's C style guide and (I believe) old K&R style recommends 8 SPACES for indent. I finally got convinced of wisdom of 8 space indentation. Guido also likes 8 space...
3
by: Gonçalo Rodrigues | last post by:
Hi, Does anyone know if and how I can, from within Python, read the signatures of builtin methods/functions? The following fails: >>> import inspect >>> inspect.getargspec(list.append)...
12
by: The Tao of Spike | last post by:
I've recentlty been getting into programming. I was wondering what language to learn first and after asking around I decided on Python. I'm about half way through "Non-Programmers Tutorial For...
9
by: Leif K-Brooks | last post by:
I try to make my code comply to the Python style guide (http://www.python.org/peps/pep-0008.html). Last time I read it, I swear that it said to use CamelCase for often-used functions and...
9
by: Jay | last post by:
I have compleated the beginers guide to python http://www.freenetpages.co.uk/hp/alan.gauld/. then i found the Toolkit Tkinter and started on that. its graight and av made lots of apps to help me...
27
by: Julien Fiore | last post by:
Do you wand to install Pyrex on Windows ? Here is a step-by-step guide explaining: A) how to install Pyrex on Windows XP. B) how to compile a Pyrex module. Julien Fiore, U. of Geneva
4
by: 4zumanga | last post by:
I have a bunch of really horrible hacked-up bash scripts which I would really like to convert to python, so I can extend and neaten them. However, I'm having some trouble mapping some constructs...
4
true911m
by: true911m | last post by:
Here's a little walkthrough to get py2exe up and running. I'm not an expert, so I can't help much with any problems you might have. This is what worked for me. The result here will be to convert...
8
by: Darren Dale | last post by:
I was just searching for some guidance on how to name packages and modules, and discovered some inconsistencies on the www.python.org. http://www.python.org/doc/essays/styleguide.html says "Module...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.