Rocking Raphsody
Rocking Raphsody

Reputation: 41

How to get all the available methods for a object in Pycharm (for ex. Pygame)

Please have a check on the screenshot, enter image description here

In that here self.image has got the pygame.image.load() method on it. but if i have to access all the available methods to self.image object, Pycharm autosuggestions does not list those.

Actually, self.image has got the get_rect to display the rectangle property of the image.

self.rect = self.image.get_rect()

import pygame


class Ship:
    def __init__(self, screen):
        self.screen = screen
        self.image = pygame.image.load('images/ship.bmp')
        self.rect = self.image.

Upvotes: 3

Views: 2518

Answers (1)

gilch
gilch

Reputation: 11651

If Pycharm isn't giving you good suggestions, that's because it can't figure out what you're looking at. Python is duck typed. What a function takes or returns could be any type. But maybe you already know what it is. Pycharm's suggestions get better if you add type annotations for your functions or variables. Use Alt+Enter when your cursor is on a function or variable declaration to add type hints.

You can also use F1 to get help for the item under the cursor and you can Ctrl+click on a variable to jump to where it was defined.

Upvotes: 4

Related Questions