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
#14
> By definition,a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.

i understand that. what i am still trying to understand is what kind of changes are done and what the decorator functions gets and can do to carry this out. one of the things it gets is a reference to the decorated function. the 2nd decoration in your code example at line 11 is @click.argument('arg', nargs=-1). where do those 2 "arguments" go? your decorated function is rm with one argument and you call it with no arguments. so how are the arguments manipulated? what if you did give an argument in the call to rm?

telling me that a decorator does make changes is not telling me how i could make use of the feature in my own programming, not just in following some example but also applying it to my own needs ... not just decorating functions i create but also writing decorator functions.

that and understanding the effect of multiple decorations and the difference between the 2 types of decorations in lines 10 and 11 of your code (the difference is arguments).

if i hand you a small gadget and you ask what it does and i say "just attach it to your car and it will save you 10% in the cost of gasoline" will you wonder how it works? then suppose you hang it from your dash window and discover your gas spending is 10% less ... will you then wonder even though you are going to leave it where it is?

i would wonder. maybe it is doing something illegal like linking to the gasoline pump an hacking in and changing the price for a while.

do you know how to write a decorator function?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: i need a module for more involved command line parsing - by Skaperen - Aug-30-2019, 03:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  module either imported by a command or itself run as a command Skaperen 2 642 Dec-04-2023, 03:15 AM
Last Post: Skaperen
  review of command line parsers Skaperen 2 2,099 Mar-11-2021, 07:39 PM
Last Post: Skaperen
  command line options Skaperen 5 2,713 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,060 Jun-22-2020, 03:42 AM
Last Post: abdulkaderanwar
  f-string in command line arguments Skaperen 0 1,624 May-05-2020, 11:49 PM
Last Post: Skaperen
  my own command line option parser Skaperen 0 1,682 Mar-27-2020, 04:14 AM
Last Post: Skaperen
  want suggested module for e-mail parsing Skaperen 0 1,562 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