>
> > ​
> This works without static/class methods and is a little less involved:
>
> ​A nice idea, but __qualname__ is Python 3 only.
>
>
The main point is to tell a function from a method. If you don't want to 
use __qualname__ one might use the inspect module.
But assuming the Python convention to name the first argument of method 
'self', the follwing works for both Python 2 and 3:

try:    # for Python 2
    self.isMethod = 'self' in func.func_code__.co_varnames
except: # for Python 3
    self.isMethod = 'self' in func.__code__.co_varnames


I used the try...except construct, so the code is not dependent on some 
global constant (ie. IS_PYTHON3).

 Any better solution to make this distictintion is welcome.

Reinhard

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to