Posted By


daeken on 07/27/06

Tagged


Statistics


Viewed 528 times
Favorited by 0 user(s)

PyObjC IVar Accessors


/ Published in: Python
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. def __getattr__(self, name):
  2. if name[0] == '_':
  3. return objc.getInstanceVariable(self, name)
  4. else:
  5. return self.__dict__[name]
  6. def __setattr__(self, name, value):
  7. if name[0] == '_':
  8. return objc.setInstanceVariable(self, name, value, 1)
  9. else:
  10. self.__dict__[name] = value
  11. return value

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.