fluentpython / example-code

Example code for the book Fluent Python, 1st Edition (O'Reilly, 2015)
http://bit.ly/fluentpy
MIT License
5.56k stars 2.18k forks source link

Adding the ability to control length to __format__ #54

Open WeiGodHorse opened 3 years ago

WeiGodHorse commented 3 years ago

Hello, I am a beginner of Python and github. I have just learned chapter 10 of Fluent Python. I noticed that in the last discussion section in chapter 10 you offered a little exercise in adding control over the length of output to the format method. I've just finished this exercise (although I feel like what I added looks jumbled) and added a few simple tests to the doctest (which may not be enough). I hope you can check whether the functions I added are correct. Meanwhile, I hope to take this opportunity to improve my python programming ability and practice the use of git and other functions. Thank you!

WeiGodHorse commented 3 years ago

And I made some minor changes to the abs and bool functions. abs still uses 'math.hypot' as in Vector2d, while bool uses 'any'.