Return to Snippet

Revision: 670
at July 27, 2006 10:59 by daeken


Updated Code
def __getattr__(self, name):
	if name[0] == '_':
		return objc.getInstanceVariable(self, name)
	else:
		return self.__dict__[name]
def __setattr__(self, name, value):
	if name[0] == '_':
		return objc.setInstanceVariable(self, name, value, 1)
	else:
		self.__dict__[name] = value
		return value

Revision: 669
at July 27, 2006 10:58 by daeken


Updated Code
def __getattr__(self, name):
		if name[0] == '_':
			return objc.getInstanceVariable(self, name)
		else:
			return self.__dict__[name]
	def __setattr__(self, name, value):
		if name[0] == '_':
			return objc.setInstanceVariable(self, name, value, 1)
		else:
			self.__dict__[name] = value
			return value

Revision: 668
at July 27, 2006 10:58 by daeken


Initial Code
def __getattr__(self, name):
		if name[0] == '_':
			return objc.getInstanceVariable(self, name)
		else:
			return self.__dict__[name]
	def __setattr__(self, name, value):
		if name[0] == '_':
			return objc.setInstanceVariable(self, name, value, 1)
		else:
			self.__dict__[name] = value
			return value

Initial URL

                                

Initial Description
Placing these inside a PyObjC class lets you access PyObjC instance variables starting with '_' without extra work while still allowing access to standard Python instance variables.

Initial Title
PyObjC IVar Accessors

Initial Tags
python

Initial Language
Python