W dniu 23.12.2016 o 15:14, Ian Kelly pisze:
(...)
cls.added_in_init = 'test'
Man, you are awsome genius! Finally somebody was able to explain me what
is the power of __new__ and difference between __init__ !!!
So what I wanted to achieve was adding some new attributes to the class
ins
On Fri, Dec 23, 2016 at 5:14 AM, Mr. Wrobel wrote:
> Hi,thanx for answers, let's imagine that we want to add one class attribute
> for newly created classess with using __init__ in metaclass, here's an
> example:
>
> #!/usr/bin/env python
>
> class MetaClass(type):
> # __init__ manipulation:
>
W dniu 21.12.2016 o 02:51, Ethan Furman pisze:
On 12/20/2016 03:39 PM, Ben Finney wrote:
"Mr. Wrobel" writes:
Quick question, can anybody tell me when to use __init__ instead of
__new__ in meta programming?
Use ‘__new__’ to do the work of *creating* one instance from nothing;
allocating the
On 12/20/2016 03:39 PM, Ben Finney wrote:
"Mr. Wrobel" writes:
Quick question, can anybody tell me when to use __init__ instead of
__new__ in meta programming?
Use ‘__new__’ to do the work of *creating* one instance from nothing;
allocating the storage, determining the type, etc. — anything
On 12/20/2016 03:26 PM, Ian Kelly wrote:
... The latter is interesting mostly because it allows you to set the
__slots__ or do something interesting with the __prepare__ hook
(although the only interesting thing I've ever seen done with
__prepare__ is to use an OrderedDict to preserve the the de
"Mr. Wrobel" writes:
> Quick question, can anybody tell me when to use __init__ instead of
> __new__ in meta programming?
Use ‘__new__’ to do the work of *creating* one instance from nothing;
allocating the storage, determining the type, etc. — anything that will
be *the same* for every instance
On Tue, Dec 20, 2016 at 2:04 PM, Mr. Wrobel wrote:
> Hi,
>
> Quick question, can anybody tell me when to use __init__ instead of __new__
> in meta programming?
>
> I see that __new__ can be used mostly when I want to manipulate with class
> variables that are stored into dictionary.
>
> But when t
Hi,
Quick question, can anybody tell me when to use __init__ instead of
__new__ in meta programming?
I see that __new__ can be used mostly when I want to manipulate with
class variables that are stored into dictionary.
But when to use __init__? Any example?
Thanx,
M
--
https://mail.python.