Python Forum
[SOLVED] Good way to handle input args?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Good way to handle input args?
#1
Hello,

My script could be called with either discrete filenames or a glob:

#myscript.py file1.txt file2.txt
#myscript.py *.txt

for item in sys.argv[1:]:
for file in glob.glob(sys.argv[1]):
Before I hack something, do you know of a good way to handle both cases?

Thank you.
Reply


Messages In This Thread
[SOLVED] Good way to handle input args? - by Winfried - May-18-2021, 06:00 PM
RE: Good way to handle input args? - by bowlofred - May-18-2021, 07:13 PM
RE: Good way to handle input args? - by Winfried - May-18-2021, 07:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Sad [Solved] I'm not getting the good type slain 18 566 Apr-11-2024, 01:36 PM
Last Post: slain
Question How to compare two parameters in a function that has *args? Milan 4 1,268 Mar-26-2023, 07:43 PM
Last Post: Milan
  [SOLVED] Input parameter: Single file or glob? Winfried 0 1,585 Sep-10-2021, 11:54 AM
Last Post: Winfried
  *args implementation and clarification about tuple status amjass12 10 4,032 Jul-07-2021, 10:29 AM
Last Post: amjass12
  Two Questions, *args and //= beginner721 8 3,495 Feb-01-2021, 09:11 AM
Last Post: buran
  does yield support variable args? Skaperen 0 1,676 Mar-03-2020, 02:44 AM
Last Post: Skaperen
  is there a way: repeat key word args Skaperen 2 2,239 Feb-03-2020, 06:03 PM
Last Post: Skaperen
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,741 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  Using function *args to multiply multiple arguments allusernametaken 8 6,081 Nov-20-2019, 12:01 AM
Last Post: allusernametaken
  Passing string args to Popen CardBoy 3 4,242 Jan-16-2018, 09:22 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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