Q: argparse.add_argument()

Thomas Passin list1 at tompassin.net
Sat Mar 18 17:59:39 EDT 2023


On 3/18/2023 4:05 PM, Chris Angelico wrote:
> On Sun, 19 Mar 2023 at 06:35, Gisle Vanem via Python-list
> <python-list at python.org> wrote:
>>
>> Thomas Passin wrote:
>>
>>> Are you trying to troll here?
>>>
>> You just showed how you got an error with this construction, so why are you asking how to
>>> get an error with this construction?
>>
>> I meant (obviously), another error-message besides:
>>     error: unrecognized arguments: -cn
>>
>> Perhaps from 'parser.add_argument ("-c, --clean", dest="clean", action="store_true")'
>>     error: "-c, --clean", 2 options are unsupported.
>>
>> BTW, accusing someone of 'trolling' is rather rude IMHO.
>> And thanks to ChrisA for a nice and normal answer.

I apologize for putting it that way.  I did have a reason for wondering 
about the post, but another time I wouldn't express it like that. 
Really, this is more general - about how to be more effective when 
asking for help.

> I suspect the reason you were accused of trolling was that it was
> quite unobvious what the difference was. When you ask for help with
> something where the distinction is subtle (and you generally know it
> was subtle by how long it took you to spot it!), it's often valuable
> to pinpoint the exact issue, so people don't gloss over it and think
> you posted the same code twice.

I did notice the difference, although I had to read it carefully a few 
times.  What I picked up on was that the OP wrote

"So is there something that throws an error on this wrong use..."

immediately after writing

"So any use of 'my-prog.py -cn' threw an error..."

To me that reads "using 'cn' as a parameter gave an error.  Is there 
something that will give this error?".  The question doesn't make sense 
that way - the OP *already* has "something" that gives the error.  So 
either the OP meant something else - and why should I need to guess what 
it was? - or ... [troll, maybe? :)].

So please, try to think out how your questions will seem to the reader, 
and be clear about what you are asking.  You may not know the 
terminology that some other people use, but don't let that stop you from 
being clear about what you really need to find out.  Including more 
context is likely to be helpful, too.  Don't leave it to the readers to 
infer what you were thinking of.

Perhaps some people who ask for help do not realize it, but to 
understand clearly what a situation and question are, and to work out 
and write (and edit) a helpful reply, perhaps with some code that needed 
to be checked first - that takes time and care.




More information about the Python-list mailing list