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
#20
i took a quick look at that first video. i think i might be able to understand that after a few views. but that will have to wait until i have plenty of time.

i'm looking at argparse. how would you set up this?

a program can be run with either one argument or two arguments. if two arguments they must both be int or float. if float, the program needs the original fraction string so it can scale the number accurately (avoiding float rounding). what the program finally needs is both numbers scaled up by 10**18 as ints without losing any digits. negative values are not valid. decimal could do this, but the values must finally be int scaled up by 10**18.

if there is only one argument, it may be a time with a : character. the format could be one of these 3 (HH:MM:SS or HH:MM or :MM:SS). the missing units are made to be 0. HH must not be greater than 23. MM and SS must not be greater than 59. the units are only given as decimal even if there is a leading zero. more than two digits for any unit is invalid even if numerically it would be. negative values are not invalid.

so what kind of .add_argument() (or other) calls could do this with argparse?
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 - Sep-02-2019, 03: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 643 Dec-04-2023, 03:15 AM
Last Post: Skaperen
  review of command line parsers Skaperen 2 2,106 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,063 Jun-22-2020, 03:42 AM
Last Post: abdulkaderanwar
  f-string in command line arguments Skaperen 0 1,626 May-05-2020, 11:49 PM
Last Post: Skaperen
  my own command line option parser Skaperen 0 1,683 Mar-27-2020, 04:14 AM
Last Post: Skaperen
  want suggested module for e-mail parsing Skaperen 0 1,564 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