I am looping a array of objects in python,
class Day():
def __init__(self,date,month,year):
self.date = date
self.month = month
self.year = year
days = [Day(12,3,23),Day(13,3,23),Day(14,3,23)]
for i,val in enumerate(days):
print(val.date)
Now I need to specify the type of val as Day,so it knows what its attributes are inside the loop,and throw suggestions while typing.
I am thinking of something like
val:Day() for i,val in enumerate(days):
But this throws errors,Is there any way to specify datatype explicitly
EDIT : The use case is just not to add it for readability but object's attributes would appear in suggestion throughout the loop ,if variable type is known,none of the mentioned methods in How do I annotate types in a for-loop? work for the suggestion part