Skip to content

Instantly share code, notes, and snippets.

@apalii
Last active November 6, 2015 18:08
Show Gist options
  • Save apalii/ecc7576f22274fa8308d to your computer and use it in GitHub Desktop.
Save apalii/ecc7576f22274fa8308d to your computer and use it in GitHub Desktop.
import math
class TriangleError(Exception):
"""docstring for TriangleError
error.args - single element tuple which conteins the msg passed to
the constructor"""
def __init__(self, text, sides):
super().__init__(text)
self.sides = tuple(sides)
@property
def sides(self):
return self._sides
def __str__():
return "'{}' for sides {}".format(self.args[0], self._sides)
def __repr__():
"TriangleError({!r}, {!r}".format(self.args[0], self._sides)
def triagle_areas(a, b, c):
sides = sorted((a, b, c))
if sides [2] > sides[0] + sides[1]:
raise TriangleError("Illegal troangle", sides)
p = (a + b + c) / 2
return math.sqrt(p * (p - a) * (p - b) * (p - c))
@apalii
Copy link
Author

apalii commented Nov 6, 2015

class A:
  def __init__(self, some)
    self._b = some

  @property
  def b(self):
    return self._b

  @b.setter
  def b_setter(self, val):
    self._b = val

A = A(‘123’)
print(a.b)
a.b =123

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