On Friday, April 7, 2017 at 7:49:11 PM UTC-5, Steve D'Aprano wrote:
> But for merely ordinary obfuscation caused by poor design,
> your best bet is probably to inspect Foo.__module__.
> 
> You can also try:
> 
> inspect.getsource(FooClass)
> inspect.getsourcefile(FooClass)

Hmm, I tried that code but all i got was a nameError. 

    >>> inspect.getsource(FooClass)
    
    Traceback (most recent call last):
      File "<pyshell#0>", line 1, in <module>
        inspect.getsource(FooClass)
    NameError: name 'inspect' is not defined

    >>> inspect.getsourcefile(FooClass)

    Traceback (most recent call last):
      File "<pyshell#1>", line 1, in <module>
        inspect.getsourcefile(FooClass)
    NameError: name 'inspect' is not defined

You must be using the Python version that has batteries _and_
imports included.

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

Reply via email to