- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get a list of parameter names inside Python function?
To extract the number and names of the arguments from a function or function[something] to return (“arg1”, “arg2”), we use the inspect module.
The given code is written as follows using inspect module to find the parameters inside the functions aMethod and foo.
Example
import inspect
def aMethod(arg1, arg2): pass
print(inspect.getargspec(aMethod))
def foo(a,b,c=4, *arglist, **keywords): pass
print(inspect.getargspec(foo))
Output
ArgSpec(args=['arg1', 'arg2'], varargs=None, keywords=None, defaults=None)
ArgSpec(args=['a', 'b', 'c'], varargs='arglist', keywords='keywords', defaults=(4,))
- Related Questions & Answers
- How to convert temperature from degree centigrade to Fahrenheit using C
- How to get a list of parameter names inside Python function?
- How to make a chain of function decorators in Python?
- How to calculate gross salary of a person using C Program
- How can we create recursive functions in Python?
- How to calculate sum of 5 subjects and find percentage Using C Program
- How to Calculate Area of Right angle Triangle using C Language
- How to Calculate Area of Circle using C Programming
- How To Clean Up Unnecessary Code From WordPress Header Without Plugins
- How to print hello world using C Language
- How to Calculate Area of Rectangle using C Program
- Write a C program using pointers to read in an array of integers and print its elements in reverse order.
- What are Python function attributes?
- What is SQL ?
- Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers
- How to Implement Stack Operations Using Array using C
Advertisements
ads