Skip to content

Instantly share code, notes, and snippets.

@ohlol
Created October 24, 2011 06:35
Show Gist options
  • Save ohlol/1308482 to your computer and use it in GitHub Desktop.
Save ohlol/1308482 to your computer and use it in GitHub Desktop.
In Ruby:
class Foo
attr_accessor :bar
end
f = Foo.new
f.bar = 'baz'
f.bar # => 'baz'
In Python:
class Foo(object):
@property
def bar(self):
return self.get_bar_somehow()
@setter
def bar(self, val):
return self.set_bar(val)
@craigcalef
Copy link

class Foo:
bar = 'baz'

a = Foo()
a.bar = 'derf'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment