Python Forum
Simple question concerning python dot notation.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple question concerning python dot notation.
#1
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
Reply
#2
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
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Forcing matplotlib to NOT use scientific notation when graphing sawtooth500 4 230 Mar-25-2024, 03:00 AM
Last Post: sawtooth500
  ''.join and start:stop:step notation for lists ringgeest11 2 2,380 Jun-24-2023, 06:09 AM
Last Post: ferdnyc
  issue with converting a scientific notation to standard notation thomaswfirth 4 1,300 Jun-06-2023, 06:06 PM
Last Post: rajeshgk
  Simple Question - ' defined as "a". ?' Ryan012 10 1,491 May-27-2023, 06:03 PM
Last Post: Ryan012
  notation MCL169 8 1,391 Apr-14-2023, 12:06 PM
Last Post: MCL169
  Very simple question about filenames and backslashes! garynewport 4 1,832 Jan-17-2023, 05:02 AM
Last Post: deanhystad
  Python Tkinter Simple Multithreading Question AaronCatolico1 5 1,474 Dec-14-2022, 11:35 PM
Last Post: deanhystad
  Issue in writing sql data into csv for decimal value to scientific notation mg24 8 2,877 Dec-06-2022, 11:09 AM
Last Post: mg24
  A simple "If...Else" question from a beginner Serena2022 6 1,638 Jul-11-2022, 05:59 AM
Last Post: Serena2022
  Simple arithmetic question ebolisa 5 2,008 Dec-15-2021, 04:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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