Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

Python autocompletion when using objects in dictionary

I am trying to use a dictionary containing several objects in a class Company. The dictionary contains a string year as its key and an object representing the company's balance sheet as its value.

My problem is, that when using the dictionary, I don't get autocompletion. What is the proper way to deal with this issue? Should you even use objects in dictionaries to represent attributes of another object?

Here my code:

class Company:
    balance_sheets = dict()  # List holding all balance sheets of the past 4 years

def __init__(self, ticker):
    ...
    self.balance_sheets[year] = BalanceSheet(bs[column], year)
    ...


comp = Company("AAPL")
balancesheet = comp.balance_sheets.get('2019')  # gets me balance sheet of 2019
balancesheet.ppe  # This is where I want it to autocomplete the object's attributes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...