Search code examples
pythonclassextractpyautogui

How to extract integers from class called "pyaugogui.point"?


I'm trying to use a specific integer found in something called <class 'pyautogui.Point'>, from a Python library called "pyautogui". If I type print(pyautogui.position()), I would get a result like this: Point(x=-436, y=720). How would I go about extracting the numbers from <class 'pyautogui.Point'> and putting them into their own separate variables? From what I understand this result is not a string, or an int.


Solution

  • I would try running the dir() function and see what you get.

    p = pyautogui.position()
    dir(p)
    

    This will list all the class methods and attributes. Most likely what you're seeking is something as easy as p.x or p.y

    x = p.x
    y = p.y