On Jan 16, 5:34 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote:
> > >From the base definition of a constructor: constructor is the creator
> > of an object. In this case, __new__ is technically the constructor
> > while __init__ is an initializer.
>
> > However, it is also to be noted that __init_
On Tue, 15 Jan 2008 14:02:43 -0800, Lie wrote:
> I've been in this Python mailing list for a few days, and I've noticed
> several things here: There are too many fundamentalist!
>
> Don't play stupid and all, don't be a fundamentalist. It might be true
> that __init__ isn't a constructor and __ne
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of Lie
> Sent: Tuesday, January 15, 2008 5:03 PM
> To: python-list@python.org
> Subject: Re: __init__ explanation please
>
> I've been in this Python mailing list for
I've been in this Python mailing list for a few days, and I've noticed
several things here: There are too many fundamentalist!
Don't play stupid and all, don't be a fundamentalist. It might be true
that __init__ isn't a constructor and __new__ might be the constructor
(some people even claimed __n
Bruno Desthuilliers <[EMAIL PROTECTED]>
writes:
> So while it's true that __init__ is the closest equivalent to what
> C++ and Java (and possibly a couple "other languages") call a
> constructor, it doesn't imply that you should refer to it as "the
> constructor". As Neil Cerutti points out, there
Hrvoje Niksic a écrit :
> Ben Finney <[EMAIL PROTECTED]> writes:
>
>> Hrvoje Niksic <[EMAIL PROTECTED]> writes:
>>
>>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
__init__() /initializes/ an instance (automatically after
creation). It is called, /after/ the instance has been constr
Hrvoje Niksic <[EMAIL PROTECTED]> writes:
> Ben Finney <[EMAIL PROTECTED]> writes:
>
> > Hrvoje Niksic <[EMAIL PROTECTED]> writes:
> >> __init__ *is* the closest equivalent to what other languages
> >> would call a constructor.
> >
> > No. That would be '__new__', which actually constructs the
>
On Tue, 15 Jan 2008 00:00:45 +0100, Hrvoje Niksic wrote:
> Ben Finney <[EMAIL PROTECTED]> writes:
>
>> Hrvoje Niksic <[EMAIL PROTECTED]> writes:
>>
>>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
>>> > __init__() /initializes/ an instance (automatically after creation).
>>> > It is called,
Ben Finney <[EMAIL PROTECTED]> writes:
> Hrvoje Niksic <[EMAIL PROTECTED]> writes:
>
>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
>> > __init__() /initializes/ an instance (automatically after
>> > creation). It is called, /after/ the instance has been constructed
>>
>> I don't understand
Hrvoje Niksic <[EMAIL PROTECTED]> writes:
> Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
> > __init__() /initializes/ an instance (automatically after
> > creation). It is called, /after/ the instance has been constructed
>
> I don't understand the purpose of this "correction". After all,
>
On Mon, 14 Jan 2008 22:18:44 +1100, Ben Finney wrote:
> What one is "in reality" calling is the '__new__' method of the Person
> class. That function, in turn, is creating a new Person instance, and
> calling the '__init__' method of the newly-created instance. Finally,
> the '__new__' method retu
"Reedick, Andrew" <[EMAIL PROTECTED]> writes:
>> Only if by "construct" you mean "allocate". __init__ starts out
>> with an empty object and brings it to a valid state, therefore
>> "constructing" the object you end up with. That operation is
>> exactly what other languages call a constructor.
>
On Jan 14, 2008 12:08 PM, Reedick, Andrew <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of Hrvoje Niksic
> > Sent: Monday, January 14, 2008 11:29 AM
> > Only if by "construct" you mean "allocate". __init__ star
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of Hrvoje Niksic
> Sent: Monday, January 14, 2008 11:29 AM
> To: python-list@python.org
> Subject: Re: __init__ explanation please
>
> Mel <[EMAIL PROTECTED]> writ
Mel <[EMAIL PROTECTED]> writes:
>> I don't understand the purpose of this "correction". After all,
>> __init__ *is* the closest equivalent to what other languages would
>> call a constructor.
>
> Nevertheless, __init__ doesn't construct anything.
Only if by "construct" you mean "allocate". __
Hrvoje Niksic wrote:
> Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
>
>> Jeroen Ruigrok van der Werven wrote:
>>> To restate it more correctly: __init__ is akin to a constructor.
>>>
>> No. See Hrvoje Niksic's reply (and Ben Finney's to which it was a
>> reply).
>>
>> __init__() /initializes/
Wildemar Wildenburger <[EMAIL PROTECTED]> writes:
> Jeroen Ruigrok van der Werven wrote:
>> To restate it more correctly: __init__ is akin to a constructor.
>>
> No. See Hrvoje Niksic's reply (and Ben Finney's to which it was a
> reply).
>
> __init__() /initializes/ an instance (automatically afte
Jeroen Ruigrok van der Werven wrote:
> To restate it more correctly: __init__ is akin to a constructor.
>
No. See Hrvoje Niksic's reply (and Ben Finney's to which it was a reply).
__init__() /initializes/ an instance (automatically after creation). It
is called, /after/ the instance has been con
Ben Finney <[EMAIL PROTECTED]> writes:
> What one is "in reality" calling is the '__new__' method of the Person
> class. That function, in turn, is creating a new Person instance, and
> calling the '__init__' method of the newly-created instance. Finally,
> the '__new__' method returns that insta
-On [20080113 14:03], Ben Finney ([EMAIL PROTECTED]) wrote:
>That's getting the two of them confused. __new__ is a constructor,
>__init__ is not.
And there I just sent an email stating the wrong thing.
I'll dig into it again, because I am really confusing something here (and
jumping between 4 lan
-On [20080113 13:36], Fredrik Lundh ([EMAIL PROTECTED]) wrote:
>given that they do different things, I'm not sure it's that helpful to
>describe them *both* as constructors.
I am still behind in my learning. ;)
To restate it more correctly: __init__ is akin to a constructor.
I am not entirely s
"A.T.Hofkamp" <[EMAIL PROTECTED]> writes:
> while you think you are doing "Person('me', 'here', 31)", you are in
> reality executing "Person.__init__(self, 'me', 'here', 31)", where
> 'self' is refers to a shiny new, empty object created for you.
This is misleading, and founders on many discrepan
On 2008-01-13, Erik Lind <[EMAIL PROTECTED]> wrote:
> I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
> online and can write simple modules, but I still don't get when __init__
> needs to be used as opposed to creating a class instance by assignment. For
> some strange re
Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> writes:
> -On [20080113 01:41], Erik Lind ([EMAIL PROTECTED]) wrote:
> >I'm new to Python, and OOP. I've read most of Mark Lutz's book and
> >more online and can write simple modules, but I still don't get
> >when __init__ needs to be used as oppos
Erik Lind wrote:
> I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
> online and can write simple modules, but I still don't get when __init__
> needs to be used as opposed to creating a class instance by assignment.
nothing is ever created by plain assignment in Python;
Jeroen Ruigrok van der Werven wrote:
> I personally tend to see __init__ or __new__ as equivalent to what other
> languages call a constructor.
>
> (And I am sure some people might disagree with that. ;))
given that they do different things, I'm not sure it's that helpful to
describe them *both
-On [20080113 01:41], Erik Lind ([EMAIL PROTECTED]) wrote:
>I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
>online and can write simple modules, but I still don't get when __init__
>needs to be used as opposed to creating a class instance by assignment.
I personally tend
Please keep discussion on the list..
> > I'm not sure if I understand your question correctly but maybe this will
> > help:
> >
> > If you want code to be run upon creating an instance of your class you
> > would use __init__. Most common examples include setting attributes on
> > the instance
Erik Lind wrote:
> I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
> online and can write simple modules, but I still don't get when __init__
> needs to be used as opposed to creating a class instance by assignment. For
> some strange reason the literature seems to take t
> I'm new to Python, and OOP. I've read most of Mark Lutz's book and more
> online and can write simple modules, but I still don't get when __init__
> needs to be used as opposed to creating a class instance by assignment. For
> some strange reason the literature seems to take this for granted. I'd
30 matches
Mail list logo