473,387 Members | 1,497 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,387 software developers and data experts.

determining the source code and module based on the class

alf
Hi,

Let's say I have a class defined somewhere:

class A:
pass

now I import (indirectly) a module defining that class (and in fact
thousands of others defined in hundreds of modules) where all I have is
a list of them provided:

l=[A,B,C]
now I need a piece of code which based on the class name can point to
the module as well as the line number where the given class is defined.

Is it doable in Python?
--
alf
Jul 16 '07 #1
1 972
On Jul 16, 6:55 am, alf <ask@mewrote:
....
now I need a piece of code which based on the class name can point to
the module as well as the line number where the given class is defined.

Is it doable in Python?
look in the inspect module.

-- bjorn

Jul 16 '07 #2

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

Similar topics

1
by: M.E.Farmer | last post by:
Hello c.l.py!, I have just finished this and decided to share. PySourceColor is a module to convert Python source into colored html. Yes it has been done before, but I like this better:) You can...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
12
by: johny smith | last post by:
I am trying to figure out a way to print the address of what called a certain function once inside the function. I am assuming that this information is on the stack somewhere. But can someone...
2
by: Ryan | last post by:
Access97 I hope someone out there can help. This is driving me crazy. Basically, I am trying to recreate VBA's built in navigation feature (The one that allows you to move first, next,...
2
by: enrio | last post by:
I need to process the source code associated with the forms outside access, and import the changes back to Access. I find that I can export the source code of a form, but when I subsequently...
0
by: Patrick Bouffard | last post by:
I have a fairly large library of Python code, where 'from package import *' is used rather liberally, and it's not uncommon for more than one of these to appear in any given module. What I'd like...
1
by: Robert Kern | last post by:
Patrick Bouffard wrote: I don't know of any automatic tools. I usually comment out those import statements and use pyflakes to show me the undefined names. -- Robert Kern "I have come to...
0
by: Egor Zindy | last post by:
Egor Zindy wrote: #!/usr/bin/env python """ A generic chipid library based on ctypes This module handles most of the functions in FTChipID.dll
6
by: Paul Wilson | last post by:
Hi all, I'd like to be able to do the following to a python source file programmatically: * Read in a source file * Add/Remove/Edit Classes, methods, functions * Add/Remove/Edit Decorators *...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.