[Tutor] initialization of classes.

alan.gauld@bt.com alan.gauld@bt.com
Mon, 12 Feb 2001 17:34:23 -0000


> Here is a Problem:

> class connection:
> 	def __init__ (...
> 		l_user_info = c_user_info(), ...

Tries to instantiate the class and assign the instance 
as the default value for the constructor. I suspect you 
really want:

> 		l_user_info = c_user_info, ...
And within the init method:
		# create an instance of whatever kind of 
		# class was passed.
              l_user_instance = l_user_info()

> class c_user_info:
> 	def __init__(self): ...

> #============  Error Start =============================
> => dsv.py 20010120.dat
> Traceback (most recent call last):
>   File "dsv.py", line 46, in ?
>     class connection:
>   File "dsv.py", line 49, in connection
>     def __init__ \
> NameError: There is no variable named 'c_user_info'

The NameError is because you haven't defined this 
class yet. Try reversing the order of your classes....

Alan G.