Il Wed, 15 Aug 2007 19:01:17 +0200, Lawrence Oluyede ha scritto:

> Torsten Bronger <[EMAIL PROTECTED]> wrote:
>> How can I get a list with all classes defined in the current module?
>> Thank you!
> 
> [EMAIL PROTECTED] ~ % cat > t.py
> class A: pass
> 
> [EMAIL PROTECTED] ~ % python
> Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple
> Computer, Inc. build 5367)] on darwin Type "help", "copyright",
> "credits" or "license" for more information.
>>>> import t
>>>> print dir(t)
> ['A', '__builtins__', '__doc__', '__file__', '__name__']
> 
> Now you have the list of names. To find out if they are actual classes
> or not you can do this:


to get names' list you can simply call globals()

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

Reply via email to