여러 속성을 가진 사용자 정의 Python 객체 목록에서 함수를 반복하고 호출하는 방법이 있습니까? 엔트리라는 속성 이름과 나이가 있다고 가정 해 봅시다.파이썬 객체 목록을 통한 Map/Iterating
이러한 내가 즉,이 경우에도 유효한 경우 functools.partial()하지만 확실하지 않은 사용에 대한 생각
def func(name, age):
//do something
def start(list_of_entries)
map(func, list_of_entries.name(), list_of_entries.age())
//but obviously the .name and .age of the object, not the iterable
//these are the only two attributes of the class
의 효과에 뭔가를 말할 수있다.
'name' 및 func''에서'age'에 액세스하는 이유는 충분한 이유가되지인가? –
왜 list_of_entries의 각 항목을 func()에 전달한 다음 전달한 객체를 통해 name/age에 액세스 할 수 있습니까? –
계산 : "list_of_entries.name()"지도를 사용할 수 있습니다! –