Skip to content

Instantly share code, notes, and snippets.

@sloria sloria/gist:5895679
Last active Mar 5, 2019

Embed
What would you like to do?
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
@classmethod
def polar(cls, r, theta):
return cls(r * cos(theta),
r * sin(theta))
point = Point.polar(r=13, theta=22.6)
@gmjosack

This comment has been minimized.

Copy link

gmjosack commented Feb 28, 2014

theta=22.6

@cbg

This comment has been minimized.

Copy link

cbg commented Feb 28, 2014

(Looks like the gist comment doesn't want to preserve my spacing). Suggestion: Line up the r * sin(theta) under r * cos(theta)
to conform to PEP 8.

@dhaffner

This comment has been minimized.

Copy link

dhaffner commented Feb 28, 2014

The arguments for polar should be named (line 6) to match the call on line 10. Better yet, the call on line 10 should be changed to have positional arguments so that it matches the original constructor for Point

@ludat

This comment has been minimized.

Copy link

ludat commented Feb 28, 2014

missed one underscore on the second line

@sloria

This comment has been minimized.

Copy link
Owner Author

sloria commented Feb 28, 2014

Fixed. Thanks for the suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.