Skip to content

Instantly share code, notes, and snippets.

@mingyc
Created March 22, 2012 11:22
Show Gist options
  • Save mingyc/2157757 to your computer and use it in GitHub Desktop.
Save mingyc/2157757 to your computer and use it in GitHub Desktop.
A simple Circle module with radius setter.
class Circle(object):
def __init__(self, value):
self.radius = None
self.set_radius(value)
def set_radius(self, value):
if value < 0:
raise ValueError('radius must be positive: {0}'.format(value))
self.radius = value
circle = Circle(3)
print circle.radius
circle.set_radius(10) # ugly usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment