Python Forum
How do classes work? (rectangle)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do classes work? (rectangle)
#4
you are using so called old-style string formatting.
Here is comparison between old-style and str.format() method
https://pyformat.info/
And with 3.6+ came even better - f-strings
One recommendation would be to use f-strings or str.format() method

Another recommendation - you need 1 point (x an y), height and width of the rectangle. These are 4 arguments to __init__()
There is no need to add second pair of x and y coordinates. You face the risk that there is discrepancy between x, y, height, width and supplied second point. In other words - select to request one point (e.g. upper-left, lower-right, lower-left or upper-right) and having also height and width calculate rest 3
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
How do classes work? (rectangle) - by GFreenD - Sep-17-2019, 03:41 PM
RE: How do classes work? (rectangle) - by GFreenD - Sep-18-2019, 07:38 PM
RE: How do classes work? (rectangle) - by buran - Sep-18-2019, 07:56 PM
RE: How do classes work? (rectangle) - by GFreenD - Sep-19-2019, 05:44 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020