Created
August 9, 2012 12:59
-
-
Save ties/3303992 to your computer and use it in GitHub Desktop.
namedtuple + property = elegant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
class Resolution(namedtuple('_Resolution', ['width', 'height'])): | |
@property | |
def pixels(self): | |
return self.width * self.height |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment