{"action":"created","issue":{"url":"https://api.github.com/repos/codecombat/codecombat/issues/2113","labels_url":"https://api.github.com/repos/codecombat/codecombat/issues/2113/labels{/name}","comments_url":"https://api.github.com/repos/codecombat/codecombat/issues/2113/comments","events_url":"https://api.github.com/repos/codecombat/codecombat/issues/2113/events","html_url":"https://github.com/codecombat/codecombat/issues/2113","id":54674173,"number":2113,"title":"Python list comprehension creates array of undefineds","user":{"login":"delve","id":44935,"avatar_url":"https://avatars.githubusercontent.com/u/44935?v=3","gravatar_id":"","url":"https://api.github.com/users/delve","html_url":"https://github.com/delve","followers_url":"https://api.github.com/users/delve/followers","following_url":"https://api.github.com/users/delve/following{/other_user}","gists_url":"https://api.github.com/users/delve/gists{/gist_id}","starred_url":"https://api.github.com/users/delve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delve/subscriptions","organizations_url":"https://api.github.com/users/delve/orgs","repos_url":"https://api.github.com/users/delve/repos","events_url":"https://api.github.com/users/delve/events{/privacy}","received_events_url":"https://api.github.com/users/delve/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/codecombat/codecombat/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-17T20:32:21Z","updated_at":"2015-10-10T12:34:48Z","closed_at":null,"body":"I'm trying to use a list comprehension to filter the list created by findEnemies().\r\n```\r\n    enemies = self.findEnemies()\r\n    if len(enemies):\r\n        notMunchkins = [x for x in enemies if x.type != \"munchkin\"]\r\n        if len(notMunchkins) > 0:\r\n            self.say(len(notMunchkins))\r\n            self.say(notMunchkins[0].type)\r\n```\r\nThis creates what appears to be a list of undefined objects. \r\n```self.say(len(notMunchkins))``` says \"2\"\r\n```self.say(notMunchkins[0].type)``` fails with \"Cannot read property 'type' of undefined\"\r\nIf I try ```distanceTo(notMunchkins[0])``` it fails with \"distance to target is null\". \r\n\r\nHave I botched my list comprehension somewhere or is this not working?"},"comment":{"url":"https://api.github.com/repos/codecombat/codecombat/issues/comments/147085429","html_url":"https://github.com/codecombat/codecombat/issues/2113#issuecomment-147085429","issue_url":"https://api.github.com/repos/codecombat/codecombat/issues/2113","id":147085429,"user":{"login":"goerlitz","id":2389436,"avatar_url":"https://avatars.githubusercontent.com/u/2389436?v=3","gravatar_id":"","url":"https://api.github.com/users/goerlitz","html_url":"https://github.com/goerlitz","followers_url":"https://api.github.com/users/goerlitz/followers","following_url":"https://api.github.com/users/goerlitz/following{/other_user}","gists_url":"https://api.github.com/users/goerlitz/gists{/gist_id}","starred_url":"https://api.github.com/users/goerlitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goerlitz/subscriptions","organizations_url":"https://api.github.com/users/goerlitz/orgs","repos_url":"https://api.github.com/users/goerlitz/repos","events_url":"https://api.github.com/users/goerlitz/events{/privacy}","received_events_url":"https://api.github.com/users/goerlitz/received_events","type":"User","site_admin":false},"created_at":"2015-10-10T12:34:48Z","updated_at":"2015-10-10T12:34:48Z","body":"Hi,\r\nthis problem still persists and it is really annoying (I'm have been using if statements and list comprehensions quite a lot of in my code and I was always stupefied why it did not work as expected). Here is some minimal code for further illustration (which I used for kilthgard-brawl):\r\n\r\n```python\r\nloop:\r\n    throwers = self.findByType(\"thrower\", self.findEnemies())\r\n    if throwers:\r\n        nearest = self.findNearest(throwers)\r\n        others = [t for t in throwers if not t is nearest]\r\n        self.say(others + \" - \" + throwers)\r\n```\r\nshows `\"[object Object] - Zara,Grel\"`, whereas\r\n\r\n```python\r\nloop:\r\n    throwers = self.findByType(\"thrower\", self.findEnemies())\r\n    while throwers:\r\n        nearest = self.findNearest(throwers)\r\n        others = [t for t in throwers if not t is nearest]\r\n        self.say(others + \" - \" + throwers)\r\n        throwers = self.findByType(\"thrower\", self.findEnemies())\r\n```\r\nshows `\"[Zara] - Zara,Grel\"`.\r\n\r\nI cannot even use `type(others)` to figure out what kind of object that is. Moreover, why is my list enclosed in square brackets and the one returned by the API not?"}}