Re: any ways to judge whether an object is initilized or not in a class

2007-03-25 Thread Antoon Pardon
On 2007-03-20, Alex Martelli <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >... >> There are plenty of reasons for preferring new style classes. If those >> reasons hold for you, then of course you should use new style classes. >> >> But that's not the same thing as s

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Aahz
In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >Not officially yet, true. But come on, it's been 6 (six) years since >type unification, and it has always been obvious (to me at least) that >the new object model was to replace the 'classic' one. ...in Python 3.0

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers wrote: > > [deploying weapons of mass snippage] Lol !-) > >>>Otherwise, the choice between old >>>and new is not very important. >> >>Your opinion. Too bad you're missing some of the most powerful parts of >>th

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers complained about > classic classes: > > >>>What's wrong with old-style classes? >> >>Almost everything. > > > That's rather an exaggeration, don't you think? Oh, really ?-) -- http://mail.python.org/mailman/l

Choosing new-style vs classic classes (was Re: any ways to judge whether an object is initilized or not in a class)

2007-03-20 Thread Aahz
In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Tue, 20 Mar 2007 08:27:07 -0700, Alex Martelli wrote: >> >> You should always use new-style classes in order to avoid having to stop >> and make a decision each time you code a class -- having to stop and ask >> yoursel

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Steven D'Aprano
On Tue, 20 Mar 2007 08:27:07 -0700, Alex Martelli wrote: > You should always use new-style classes in order to avoid having to stop > and make a decision each time you code a class -- having to stop and ask > yourself "do I need any of the many extra features of new-style classes > here, or will l

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > There are plenty of reasons for preferring new style classes. If those > reasons hold for you, then of course you should use new style classes. > > But that's not the same thing as saying that you should use new style > classes *even when you don

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Steven D'Aprano
On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers complained about classic classes: >> What's wrong with old-style classes? > > Almost everything. That's rather an exaggeration, don't you think? They have methods, and inheritance, and attributes, all the critical features of classes, and

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Steven D'Aprano
On Tue, 20 Mar 2007 10:28:10 +0100, Bruno Desthuilliers wrote: [deploying weapons of mass snippage] >> Otherwise, the choice between old >> and new is not very important. > > Your opinion. Too bad you're missing some of the most powerful parts of > the language. Yes, it is my opinion, and it s

Re: any ways to judge whether an object is initilized or not in a class

2007-03-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Mon, 19 Mar 2007 19:48:37 +1100, Ben Finney wrote: > >> It's also best to inherit every class from another class, leading to a >> single hierarchy for all classes and types. 'object' is the one to >> choose if you don't want the behaviour of any other class. > > Wha

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Steve Holden
Steven D'Aprano wrote: > On Mon, 19 Mar 2007 19:48:37 +1100, Ben Finney wrote: > >> It's also best to inherit every class from another class, leading to a >> single hierarchy for all classes and types. 'object' is the one to >> choose if you don't want the behaviour of any other class. > > What's

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Ben Finney
"Steven D'Aprano" <[EMAIL PROTECTED]> writes: > On Mon, 19 Mar 2007 19:48:37 +1100, Ben Finney wrote: > > > It's also best to inherit every class from another class, leading > > to a single hierarchy for all classes and types. 'object' is the > > one to choose if you don't want the behaviour of an

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Steven D'Aprano
On Mon, 19 Mar 2007 19:48:37 +1100, Ben Finney wrote: > It's also best to inherit every class from another class, leading to a > single hierarchy for all classes and types. 'object' is the one to > choose if you don't want the behaviour of any other class. What's wrong with old-style classes? On

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread greg
Gabriel Genellina wrote: > you may consider using a class > attribute as a default value: > > class Coffee: > > temp = 50 Be careful with that, though -- only use it for immutable values. Doing that with a mutable object, such as a list, will get you into trouble, since one object is being

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Bruno Desthuilliers
Steve Holden a écrit : > Bruno Desthuilliers wrote: > >> Diez B. Roggisch a écrit : >> (snip) >>> You want boil to be called __init__, which is python's constructor name. >> >> >> Actually, __init__ is the initializer. The proper constructor is __new__. >> >> > I'm not sure Diez qualifies as

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Steve Holden
Bruno Desthuilliers wrote: > Diez B. Roggisch a écrit : >> momobear schrieb: >>> hi, I am puzzled about how to determine whether an object is >>> initilized in one class, anyone could give me any instructions? >>> here is an example code: >>> >>> class coffee: >>> def boil(self): >>>

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Gabriel Genellina
En Mon, 19 Mar 2007 05:35:00 -0300, momobear <[EMAIL PROTECTED]> escribió: >> > in C++ language we must initilized a variable first, so there is no >> > such problem, but in python if we don't invoke a.boil(), we will not >> > get self.temp to be initilized, any way to determine if it's initilzed

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Bruno Desthuilliers
momobear a écrit : > hi, I am puzzled about how to determine whether an object is > initilized in one class, anyone could give me any instructions? > here is an example code: > > class coffee: > def boil(self): >self.temp = 80 > > a = coffer() > if a.temp > 60: > pr

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : > momobear schrieb: >> hi, I am puzzled about how to determine whether an object is >> initilized in one class, anyone could give me any instructions? >> here is an example code: >> >> class coffee: >> def boil(self): >>self.temp = 80 >> >> a = c

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Duncan Booth
"momobear" <[EMAIL PROTECTED]> wrote: > thanks for help:), I am puzzled about if I have to use try and except > to determine it. finnal code should like this? > class coffee: > def __init__(self): > ''' > do something here > ''' > def b

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread momobear
On Mar 19, 4:50 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > "momobear" <[EMAIL PROTECTED]> wrote: > > in C++ language we must initilized a variable first, so there is no > > such problem, but in python if we don't invoke a.boil(), we will not > > get self.temp to be initilized, any way to determi

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread James Stroud
momobear wrote: > hi, I am puzzled about how to determine whether an object is > initilized in one class, anyone could give me any instructions? > here is an example code: > > class coffee: > def boil(self): >self.temp = 80 > > a = coffer() > if a.temp > 60: > print

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Duncan Booth
"momobear" <[EMAIL PROTECTED]> wrote: > in C++ language we must initilized a variable first, so there is no > such problem, but in python if we don't invoke a.boil(), we will not > get self.temp to be initilized, any way to determine if it's initilzed > before self.temp be used. > The simplest th

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Ben Finney
"momobear" <[EMAIL PROTECTED]> writes: > class coffee: > def __init__(self): > ''' > do something here > ''' > def boil(self): >self.temp = 80 > > a = coffer() > if a.temp > 60: > print "it's boiled" class Coffe

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread momobear
On Mar 19, 4:19 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > momobear schrieb: > > > > > hi, I am puzzled about how to determine whether an object is > > initilized in one class, anyone could give me any instructions? > > here is an example code: > > > class coffee: > > def boil(se

Re: any ways to judge whether an object is initilized or not in a class

2007-03-19 Thread Diez B. Roggisch
momobear schrieb: > hi, I am puzzled about how to determine whether an object is > initilized in one class, anyone could give me any instructions? > here is an example code: > > class coffee: > def boil(self): >self.temp = 80 > > a = coffer() > if a.temp > 60: > pri

any ways to judge whether an object is initilized or not in a class

2007-03-18 Thread momobear
hi, I am puzzled about how to determine whether an object is initilized in one class, anyone could give me any instructions? here is an example code: class coffee: def boil(self): self.temp = 80 a = coffer() if a.temp > 60: print "it's boiled" in C++ language we mus