Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

is there a way to specify what should be in a list when passed as a parameter?

I am learning python. I have a function:

def saveQuotesAndData(self,filename:str, items:list):

but I want my VS Code intellisense to know what items[i] will be, so i can write the function with auto complete, and not manually type properties of items[i].

for example if I want to auto complete below:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

items[i].QuoteTime

maybe something like this would be perfect:

def saveQuotesAndData(self,filename:str, items:list<Quote>):

where Quote would be the expected class contained in the list.

something as simple as this is very slow in python so far for me because theres lots of manual typing and flicking back to class definitions. any suggestions here?

>Solution :

Try def saveQuotesAndData(self,filename:str, items:list[Quote])

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading