Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#10 tuple of types for nargs > 1

open
Greg Ward
5
2004-10-26
2004-10-20
Andrea Bocci
No

One more thing I'd like to implement / see is the
posssibility, for an option accepting more than one
argument, to have different types for these arguments.
I.e.,
test.py --option name 3.14

I'm woking on it, but I still have to find a solution
which is:
- elegant
- backwards compatible
- possibly, not too intrusive

Any idea?

Discussion

  • Andrea Bocci
    Andrea Bocci
    2004-10-20

    Logged In: YES
    user_id=526376

    OK, I've managed to have an option accept arguments of
    different types.
    The main modifications to the Option class are
    a new type "tuple",
    a new atrribute 'types'=("string", "float") (or whatever).
    If one sets 'type'=("string", "float") the adjustament to
    the above scheme is done automatically.

    I'm still uncertain with respect to 'nargs', ie. the example
    above shoud set 'nargs'=2 (as it consumes 2 arguments) or
    'narg'=1 (as it outputs a single tuple) ?

    Right now, it does 'nargs'=2, and doesnt accept any other
    'nargs' value.
    Commments?

    Simplest implementation is attaceh, as a patch against 1.5a1
    CVS.

     
  • Andrea Bocci
    Andrea Bocci
    2004-10-20

     
    Attachments
  • Andrea Bocci
    Andrea Bocci
    2004-10-20

    • labels: --> misc features
     
  • Greg Ward
    Greg Ward
    2004-10-26

    • assigned_to: nobody --> gward