Re: Get path of a class

2006-01-10 Thread Peter Hansen
Florian Lindner wrote:
 Hello,
 how can I get the path of a class. I managed to do it with
 
 c.__module__ + . + c.__name__
 
 but I'm sure there is a better way.

Please define what you mean by path (and how you hope to make use of 
this information).

Generally a module has a path (i.e. a location where it can be loaded 
from the file system) but classes are merely created by class 
statements within a module.  There is no one-to-one match with files, 
and in fact no requirement that a class even be traceable directly to 
statements in a source file.

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get path of a class

2006-01-10 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Florian
Lindner wrote:

 Hello,
 how can I get the path of a class. I managed to do it with
 
 c.__module__ + . + c.__name__
 
 but I'm sure there is a better way.

How about using the `inspect` module::

 In [33]: import inspect, zipfile

 In [34]: inspect.getsourcefile(zipfile.ZipInfo)
 Out[34]: '/usr/lib/python2.4/zipfile.py'

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Get path of a class

2006-01-09 Thread Florian Lindner
Hello,
how can I get the path of a class. I managed to do it with

c.__module__ + . + c.__name__

but I'm sure there is a better way.

Thanks,

Florian

-- 
http://mail.python.org/mailman/listinfo/python-list