내가 오류 "입력 오류 받고 있어요 :. 그 프델() 메서드를 호출하려고 할 때 'locationTile'는 호출 대상이 아닌 코드 : 다른통화 속성 게터, 세터, Deleter가 - 파이썬
class GamePlayLocationTiles(object):
"""The stuff needed for game play"""
_locationTiles = []
def locationTiles():
doc = "property locationTiles's doc string"
def fget(self):
return self._locationTiles[0]
def fset(self, value):
self._locationTiles = value[0]
def fdel(self):
del self._locationTiles[0]
return locals() # credit: David Niergarth
locationTiles = property(**locationTiles())
def __init__(self):
self.fill_location_tiles_list()
모듈 :.
import game_play_model
class GamePlayController:
"""perform operations on the game_play_model"""
def __init__(self):
self.the_game_location_tiles = game_play_model.GamePlayLocationTiles()
self.shuffle_location_tiles()
def shuffle_location_tiles(self):
self.the_game_location_tiles.locationTiles().fdel() //this line causes the error
def main():
the_game_play_controller = GamePlayController()
if __name__ == '__main__':
main()
그냥 게터, 세터, Deleter가있는 전용 변수 액세스에 대한 테스트로 삭제하려고
답변을 주셔서 감사합니다. getter, setter, deleter에서 fdel 등등의 코드에서 [0]을 삭제하려고 했으므로 한 멤버 만이 아니라 전체 목록을 삭제하고 _locationTiles가 읽기 전용이라는 fdel() 메서드 내부에서 오류가 발생했습니다. . 그래서 나는 그것을 얻을 수 있었지만 그것을 지울 수는 없었다. 왜 그런지 알아? – user3164083
이것은 setter, getter, deleter가있는 목록입니다. 그렇게 목록을 작성할 수는 없습니다. 이제 작동합니다. : 나는 그것을 변경 '데프 프델 (자기) : 이 self._locationTiles 델 [0 : LEN (self._locationTiles)]' 감사합니다 :) – user3164083
아,이 인스턴스가 클래스 속성을 삭제할 수 없습니다 단순히 , (최소한 그런 식으로.) – unutbu