[Tutor] initialization of classes.

Furmanek, Greg Greg.Furmanek@hit.cendant.com
Mon, 12 Feb 2001 11:57:09 -0500


Here is a Problem:

I am trying to pass a class to another class and 
initialize the passed class if it is not passed
when the main class is initialized.  

This is the piece of code and error I get.

Thanks for help.

#============  Code Start ==============================

class connection:


	def __init__ \
		(self, \
		l_acc_stat = "", \
		l_user_info = c_user_info(), \
		l_tun_type = "", \
		l_acc_info = c_acct_info(), \
		l_net_info = c_network_info()):

		self.account_status = l_acc_stat
		self.user = l_user_info
		self.Class = ""				# not used
		self.Tunnel_Type = l_tun_type
		self.acct_info = l_acc_info
		self.network_info = l_net_info


	def load_account_status(self, acc_stat):
		self.account_status = acc_stat


	def load_user_info(self, l_user_info):
		self.user = l_user_info

class c_user_info:


	def __init__(self):
		self.User_Name = ""
		self.User_Full_Name = ""
		self.User_Group = user_group 

#============  Code End   ==============================

#============  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'

#============ Error End   ==============================

Grzegorz Furmanek
Furmanek.Greg@hit.cendant.com
----------------------------------------------------------
Three Mile Island '79   Chernobyl '86   Windows '00 (1900) 


"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent.  This message
and its attachments could have been infected during transmission.  By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects.  The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."