Why can't Lists be private variables in a class

fossil_blue noelrivera at excite.com
Sun Mar 7 00:42:32 EST 2004


Why we can't define a list as a private variable in a class such as 

__SYMTAB = [ ]

class Myclass:
      def __init__(self):
		#some constructor here
     
      def __PlayWithList(arg1):
	# This doesn't work it compains about not having not having attribute
index or append
	# Why?
	try: self.__SYMTAB.index(arg1)  
	except ValueError: self.__SYMTAB.append(arg1)
   
But it the list was public SYMTAB = [ ] it would work. Why?


Thanks,
Noel



More information about the Python-list mailing list