Python Forum
i need a module for more involved command line parsing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i need a module for more involved command line parsing
#8
(Aug-26-2019, 07:31 PM)Skaperen Wrote: so what does @my_decorator really do?
It's not like the web are lacking info about decorators if you search Dodgy
First hit google Primer on Python Decorators.

In my example with @make_bold,if take away all the magic of @.
It's just functions foo get passed to make_bold function.
make_bold return new_func which added stuff to foo function.
def make_bold(fn):
    '''Do not need to see me'''
    def new_func():
        return f"<b>{fn()}</b>"
    return new_func

def foo():
    return 'python-forum'

make_bold = make_bold(foo) # The cooler way is @make_bold 
The same results.
>>> make_bold()
'<b>python-forum</b>'

Quote:are decorators always functions? what if some arbitrary function is used?
No,look at link given.
It's also used in Data Classes.

If you really need to look at source before use Click,then it's all open Click GitHub
Reply


Messages In This Thread
RE: i need a module for more involved command line parsing - by snippsat - Aug-27-2019, 08:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  module either imported by a command or itself run as a command Skaperen 2 671 Dec-04-2023, 03:15 AM
Last Post: Skaperen
  review of command line parsers Skaperen 2 2,145 Mar-11-2021, 07:39 PM
Last Post: Skaperen
  command line options Skaperen 5 2,764 Aug-14-2020, 08:48 AM
Last Post: DeaD_EyE
  opening python from the command line takes a long time to load? abdulkaderanwar 4 3,130 Jun-22-2020, 03:42 AM
Last Post: abdulkaderanwar
  f-string in command line arguments Skaperen 0 1,666 May-05-2020, 11:49 PM
Last Post: Skaperen
  my own command line option parser Skaperen 0 1,700 Mar-27-2020, 04:14 AM
Last Post: Skaperen
  want suggested module for e-mail parsing Skaperen 0 1,578 Jul-26-2019, 08:52 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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