Python Forum

Full Version: Simple question concerning python dot notation.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I do understand a fair amount about object oriented programming. But the following convention using dot notation eludes me.

Although the following code snippet is written using pygame I believe that that question that I have concerns python, specifically.

rect = surface1.get_rect()
rect = rect.move("some position here", "another position here" )
It is on the second line that I am confused. rect is declared on the first line. Then rect.move is used on the second line.

It would appear to me, and I am just guessing, that rect is declared as an object in the first line. That would mean, if correct, that "move" used in the second line would be a method declared in the "rect" class. Somewhere.

Am I close?

Thank You
Tom
Yes, you are right. rect is an instance of some class, but from your code it's not clear instance of which class is (I am not familiar with pygame, others may know which one). move() is method of that class.

EDIT: quick search - it's an instance of class Rect https://www.pygame.org/docs/ref/rect.htm....Rect.move