[NEWBIE]-Object referencing??

Alistair Campbell campbells4 at ozemail.com.au
Tue Jul 2 01:46:36 EDT 2002


Hi,

I have class defined as below

<code>
...
class Brew:

    def __init__(self):
        self.brew_id=""
        self.brew_date=""
        self.brew_type=""
        self.hydro_init='1040'
        self.hydro_final='1000'
        self.starter=""
        self.amt_start=""

    def alcohol(self):
        return
((string.atoi(self.hydro_init)-string.atoi(self.hydro_final))*0.00036251)*10
0
...
<code>

I assign data from a file so the data that goes into the alcohol method
needs to be converted from string.
The problem is that when I try to reference an instantiation of the Brew()
class, i.e;

current_brew=Brew()

I can get all the other data items but a call to;

current_brew.alcohol

returns

<bound method Brew.alcohol of <__main__.Brew instance at 0x01761250>

So. I know that the calculation of alcohol content is not true but I am just
fiddling and will put in the correct formula when I get round to it.

But, what am I doing wrong in relation to my definition or calling of the
Brew.alcohol method?

Trivial but nonetheless I have to start learning somewhere. Your help is
much appreciated.

Alistair Campbell
Brisbane, Qld





More information about the Python-list mailing list