Skip to content

Commit

Permalink
even better oop
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Nov 20, 2018
1 parent 0c1dff2 commit b4287cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exercises/oop/oop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**EXERCISE:** There is another method for getting a string representation of a Python object, called `__repr__`. Read carefully [\\_\\_repr\\_\\_ documentation](https://docs.python.org/3/reference/datamodel.html#object.__repr__) and implement the method.\n",
"**EXERCISE:** There is another method for getting a string representation of a Python object, called `__repr__`. Read carefully [\\_\\_repr\\_\\_ documentation](https://docs.python.org/3/reference/datamodel.html#object.__repr__) and implement the method. To try it and see if any difference appear with respect to str, call the standard Python functions `repr` and `str` like this:\n",
"\n",
"```\n",
"c = ComplexNumber(3,5)\n",
"print(repr(c))\n",
"print(str(c))\n",
"```\n",
"\n",
"**QUESTION**: Would `3.0 + 5.0i` be a valid Python expression ? Should we return it with `__repr__`? Read again also [\\_\\_str\\_\\_ documentation](https://docs.python.org/3/reference/datamodel.html#object.__str__) \n",
"\n"
Expand Down

0 comments on commit b4287cc

Please sign in to comment.