Home > Software design >  Updating the method references on VS code
Updating the method references on VS code

Time:01-10

I am having a hard time figuring out how to update selected references of a method from vscode. Right-clicking on the method name doesn't give the options to choose and update the references. New to Python and vscode and trying to figure out the nuances around it. Can some help me with this please!

Here are the classes - I have a class Player_Account

class Player_Account:

    def __init__(self,owner,balance):
        self.owner = owner
        self.balance = balance

    def deposit(self,balance):
        self.balance  = balance
        return "Amount added to players pot !"

    def withdraw(self,amount): # I need to update this method name to withdraw_amount
        if self.balance<amount:
            return "Funds Unavailable"
        else:
            self.balance -= amount
            return "Money added to hand !"

    def __str__(self):
        return f"Account owner : {self.owner} has outstanding balance of {self.balance}"

Another class Player

class Player:
    def __init__(self,name):
        self.name=name
        self.hand = []
        self.player_account:Player_Account = Player_Account(name,0)

    def initial_money(self,amount):
        self.player_account.balance = amount

    def player_won_the_hand(self,amount):
        self.player_account.deposit(amount)
        return True

    def player_betting_amount_for_the_round(self,amount):
        value = self.player_account.withdraw(amount) # I need this reference to be automatically updated as well
        if value == 'Funds Unavailable':
            return False
        else:
            return True

CodePudding user response:

I just tried.

  • set cursor on def withdraw
  • press F2 (rename symbol)
  • change name to withdraw_amount and press Enter
  • it takes a few seconds but both are changed

I use PyLance.

  •  Tags:  
  • Related