LeRoy Lee wrote:
> I have been searching for the answer to this as it will determine how I use 
> classes.  Here are two bits of code.

> class foo2:
>     def __init__(self):
>         self.j = 5
> 
> 
>>>h = foo2()
>>>h.j
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: foo2 instance has no attribute 'j'

Works for me (Python 2.4).

 >>> class foo2:
...     def __init__(self):
...         self.j = 5
...
 >>> h = foo2()
 >>> h.j
5

Perhaps there is some strange state in your interpreter.
--
Benji York

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to