KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Class Foo has a bar , and it is not loaded until it is accessed. Further accesses to bar should incur no overhead. class Foo(object): def get_bar(self): print "initializing" self.bar = "12345" self.get_bar = self._get_bar return self.bar def _get_bar(self): print "accessing" return self.bar Is it possible to do something like this using properties or, better yet, attributes, instead of using a getter method? The goal is to lazy load without overhead on all subsequent accesses...
Tags (comma-separated)
Save Edits
Cancel