[Tutor] variable length methods?

Daniel Ehrenberg littledanehren at yahoo.com
Fri Jan 16 17:33:09 EST 2004


--- Denis Saussus <dsaussus at jasongeo.com> wrote:
> Hello,
> 
> I would like to know if there is a special python
> version of *vargs
> specifically intended to be used with variable
> length methods instead
> of just with variable length arguments.  If there
> is, fantastic!  If
> there isn't, is it still acceptable to 'fudge'
> *vargs to do what I want?

What do you mean "variable length methods"?
> 
> For instance,
> 
> class MyClass:
>   def __init__(self, outputdir, *vargs):
>     ...
> 
> will work without any problems if you do:
> 
> MyClass mc(outputdir = 'here/',
>            a = 1,
>            b = 2,
>            c = 4,
>            ...)
> 
use **kwargs for things like a=1, b=2, c=4, etc. It
will return a dictionary of all of thosekeyword
arguments.

> but what I am seeking to do is:
> 
> MyClass mc(outputdir = 'here/',
>            plot(x),
>            plot(a,b,c),
>            plot(w,z),
>            ...)
> 
> where,
> 
> def plot(*vargs):
>    ...
> 
> Help anyone?
> 
> Thanks!

Where did the x, w, and z come from? I still don't
know what *vargs does. *args excepts however many
arguments you wan,t although it's always preferential
to use a default of None or something like that.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus



More information about the Tutor mailing list