Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:56:06+00:00 2026-06-11T09:56:06+00:00

since I got python on windows running, here is the next problem I encountered

  • 0

since I got python on windows running, here is the next problem I encountered with argparse, and for which I did not see a solution. I uses optparse before. Here is my code:

import argparse
parser = argparse.ArgumentParser(
        description = 'Test description')       # main description for help

parser.add_argument('-d', '--dir',                 # -u or --user option           
        dest = "dir",
        help = 'directory to start with')           
args = parser.parse_args()
print(args.dir)

but when I run this code with either

code.py -d test
code.py --dir test

I always get a None as output. I feel this is something trivial, and something obvious I overlooked, but I cannot see it.

Tanks

Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:56:07+00:00Added an answer on June 11, 2026 at 9:56 am

    The problem seem to be caused by Windows, and how the code is tried to be executed on the command line. In the given example the test script was called directly on the command line, without python before the code, as suggested in this answer.

    If the code is executed like

    python code.py
    

    the expected behavior is seen, and the arguments are correctly parsed in the code.

    So either the setup of the Windows system is stil incomplete, or the suggestion in the above link is incomplete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've got a server over which we're running a Django powered site. Since we
I've got a big problem, I can't launch anything from the terminal, not python,
Since my AS3 and Php/Java knowledge is not good I got stuck on this
i've got a problem with python: I want to assign a method to an
I've got a Python program that does time-consuming computations. Since it uses high CPU,
I have got python code running on multiple analyzer machines each picking documents from
So, I've got a multithreaded python program, which is currently suffering from deadlock. I
So this Python problem has been giving me problems since I've tried refactoring the
Since I got TLDR (too long didn't read) comments, I stripped 90% of this
It's been a while since I got into QCL but I ran into some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.