Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Python Feature
#2
There also inspect module that is a little more robust,as it will give all info also about default arguments and keyword arguments.
def foo(arg, new='snake', **kwargs):
    return f'python-forum {arg} a {new}? no {kwargs}'
Test:
>>> import inspect
>>> 
>>> foo.__code__.co_varnames[:foo.__code__.co_argcount]
('arg', 'new')
>>> 
>>> inspect.signature(foo)
<Signature (arg, new='snake', **kwargs)>
>>> 
>>> foo('io', python='forum')
"python-forum io a snake? no {'python': 'forum'}"
Reply


Messages In This Thread
Random Python Feature - by ichabod801 - Aug-25-2019, 02:50 PM
RE: Random Python Feature - by snippsat - Aug-25-2019, 04:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  a feature i would like to see added to Python Skaperen 0 541 Oct-30-2023, 12:30 AM
Last Post: Skaperen
  Can the video calling feature be used from python telegram bot api? Kumarkv 0 1,861 May-30-2020, 01:34 PM
Last Post: Kumarkv
  Python in Feature film Larz60+ 0 3,164 Dec-11-2016, 02:17 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020