Le 26/09/2019 à 15:17, Peter Otten a écrit :
ast wrote:
__init__ is called only if __new__ returns an instance of ClassB:
I was ignoring that. thank you
--
https://mail.python.org/mailman/listinfo/python-list
On 26/09/2019 15:35, Oscar Benjamin wrote:
On Thu, 26 Sep 2019 at 13:39, Rhodri James wrote:
You have returned the class object, not
an instance of anything,
Well object is an instance of object as well as of type:
Fair point. I keep forgetting that.
--
Rhodri James *-* Kynesim Ltd
--
http
On Thu, 26 Sep 2019 at 13:39, Rhodri James wrote:
>
> On 26/09/2019 13:20, ast wrote:
> >
> > >>> class ClassB(object):
> > ... def __new__(cls, arg):
> > ... print('__new__ ' + arg)
> > ... return object
> > ... def __init__(self, arg):
> > ... print('__init__ ' +
On Thu, 26 Sep 2019 at 14:19, Peter Otten <__pete...@web.de> wrote:
>
> __init__ is called only if __new__ returns an instance of ClassB:
>
> """
> /* If the returned object is not an instance of type,
>it won't be initialized. */
> if (!PyType_IsSubtype(Py_TYPE(obj), type))
>
ast wrote:
> Hello
>
> In the following code found here:
> https://www.pythonsheets.com/notes/python-object.html
>
> __init__ is not invoked when we create an object
> with "o = ClassB("Hello")". I don't understand why.
> I know the correct w
Le 26/09/2019 à 14:20, ast a écrit :
Hello
In the following code found here:
https://www.pythonsheets.com/notes/python-object.html
__init__ is not invoked when we create an object
with "o = ClassB("Hello")". I don't understand why.
I know the correct way to define __
On 26/09/2019 13:20, ast wrote:
Hello
In the following code found here:
https://www.pythonsheets.com/notes/python-object.html
__init__ is not invoked when we create an object
with "o = ClassB("Hello")". I don't understand why.
I know the correct way to define __new__ i
Hello
In the following code found here:
https://www.pythonsheets.com/notes/python-object.html
__init__ is not invoked when we create an object
with "o = ClassB("Hello")". I don't understand why.
I know the correct way to define __new__ is to write
"return obj