Skip to content

Instantly share code, notes, and snippets.

@simeonwillbanks
Created March 20, 2010 20:58
Show Gist options
  • Save simeonwillbanks/338903 to your computer and use it in GitHub Desktop.
Save simeonwillbanks/338903 to your computer and use it in GitHub Desktop.
Python: Property Accessors Person
class Person(object):
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
# property decorator
@property
def full_name(self):
return "%s %s" % (self.first_name, self.last_name)
me = Person("Simeon", "Willbanks")
# so clean!
print me.full_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment