Re: Checking for required arguments when instantiating class.

2009-05-07 Thread Piet van Oostrum
> Chris Rebert (CR) wrote: >CR> On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum wrote: Lacrima (L) wrote: >L> But what if I have to instantiate any class with 3 or 4 required >L> arguments? How can I do it? >>> >>> cls.__init__.im_func.__code__.co_argcount >>> >>> This will inc

Re: Checking for required arguments when instantiating class.

2009-05-07 Thread Lacrima
On May 6, 3:36 pm, Chris Rebert wrote: > On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum wrote: > > > > >> Lacrima (L) wrote: > > >>L> Hello! > >>L> For example I have two classes: > > >> class First: > >>L>     def __init__(self, *args, **kwargs): > >>L>             pass > > >> cla

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Chris Rebert
On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum wrote: >> Lacrima (L) wrote: > >>L> Hello! >>L> For example I have two classes: > >> class First: >>L>     def __init__(self, *args, **kwargs): >>L>             pass > >> class Second: >>L>     def __init__(self, somearg, *args, **kwarg

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Piet van Oostrum
> Lacrima (L) wrote: >L> Hello! >L> For example I have two classes: > class First: >L> def __init__(self, *args, **kwargs): >L> pass > class Second: >L> def __init__(self, somearg, *args, **kwargs): >L> self.somearg = somearg >L> How can I test that

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Lie Ryan
Lacrima wrote: class First: def __init__(self, *args, **kwargs): pass class Second: def __init__(self, somearg, *args, **kwargs): self.somearg = somearg How can I test that First class takes 1 required argument and Second class takes no require

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Chris Rebert
On Wed, May 6, 2009 at 3:08 AM, Lacrima wrote: > Hello! > > For example I have two classes: > class First: >        def __init__(self, *args, **kwargs): >                pass > class Second: >        def __init__(self, somearg, *args, **kwargs): >                self.somearg = somearg >

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Lacrima
> >>> class First: > >         def __init__(self, *args, **kwargs): >                 pass > > >>> class Second: > >         def __init__(self, somearg, *args, **kwargs): >                 self.somearg = somearg > > How can I test that First class takes 1 required argument and Second > class takes

Checking for required arguments when instantiating class.

2009-05-06 Thread Lacrima
Hello! For example I have two classes: >>> class First: def __init__(self, *args, **kwargs): pass >>> class Second: def __init__(self, somearg, *args, **kwargs): self.somearg = somearg How can I test that First class takes 1 required argument and