Skip to main content
clarify; make names more consistent; rm the (very confusing) bit about decorators to improve focus
Source Link
Karl Knechtel
  • 61.4k
  • 14
  • 131
  • 193

Given the Pythonthat a function: a_method has been defined like

def a_method(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I have a reference toStarting from funca_method itself, how can I wantget the func.[something] to returnargument names ("arg1", "arg2").

The usage scenario- for this is that I have a decoratorexample, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e.tuple of strings, how would the decorator look that printed "a,b" when I calllike a_method("a""arg1", "b""arg2")?

Given the Python function:

def a_method(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2").

The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e., how would the decorator look that printed "a,b" when I call a_method("a", "b")?

Given that a function a_method has been defined like

def a_method(arg1, arg2):
    pass

Starting from a_method itself, how can I get the argument names - for example, as a tuple of strings, like ("arg1", "arg2")?

Edited title to better express question and removed language tag.
Link
martineau
  • 124k
  • 29
  • 180
  • 319

Getting How to get method parameter names in Python?

use snake_case as per PEP 8
Source Link
user3064538
user3064538

Given the Python function:

def aMethoda_method(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I have a reference to funcfunc, I want the func.[something]func.[something] to return ("arg1", "arg2")("arg1", "arg2").

The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e., how would the decorator look that printed "a,b""a,b" when I call aMethod("a", "b")a_method("a", "b")?

Given the Python function:

def aMethod(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2").

The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e., how would the decorator look that printed "a,b" when I call aMethod("a", "b")?

Given the Python function:

def a_method(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2").

The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e., how would the decorator look that printed "a,b" when I call a_method("a", "b")?

Active reading [<http://en.wikipedia.org/wiki/Python_%28programming_language%29>]
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
edited tags
Link
Loading
Source Link
Staale
  • 28.1k
  • 23
  • 69
  • 85
Loading