On Thu, Oct 22, 2009 at 8:12 PM, rh0dium <steven.kl...@gmail.com> wrote:

> In my case the args that it dumps them into a black hold is simply not
> true.  I want an unknown set of args and kwargs to simply be forwarded
> onto init.  So what's the problem with this??
>

There is no problem with doing that-- the deprecation warning is just that
object.__new__ takes no arguments besides the class itself.

Within __new__ you do not need to do anything to "forward" the arguments to
__init__. Python calls first __new__, then __init__ with the arguments you
pass. You don't have to forward from one method to another.

Observe:

>>> class myclass(object):
...     def __new__(cls, *args, **kwargs):
...             print args
...             print kwargs
...             self = object.__new__(cls)
...             return self
...     def __init__(self, *args, **kwargs):
...             print args
...             print kwargs
...
>>> A = a()
()
{}
()
{}
>>> A = a(1,2,3)
(1, 2, 3)
{}
(1, 2, 3)
{}

HTH,

--S
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to