'X' object has no attribute 'y' - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32) +---- Thread: 'X' object has no attribute 'y' (/showthread.php?tid=26064) |
'X' object has no attribute 'y' - band_master - 04-23-2012 hi there, i am new to python. i installed it in order to run a script that migrates Google Analytics to Piwik, a locally hosted open source solution using MYSQL/PHP. Anyways, I was able to get python running with Google API and can run the script but I run into the following Python error: 'Action' object has no attribute 'id_action_url' Here is the code included in the file 'action.py' import sql TYPE_ACTION_URL = 1 TYPE_ACTION_NAME = 4 class action(object): def __init__(self, path, title, internal_id): self.path = path self.titles = [title] self.internal_id = internal_id self.exported = False self.pageviews = 0 self.timeleft = 0 def __repr__(self): return str(self.titles) def get_title(self): for title in self.titles: if title != None: return title return "" def export(self, base_path): path = base_path + self.path title = self.get_title() type_url = ( path, self.get_hash(path), TYPE_ACTION_URL ) type_name = ( title, self.get_hash(title + path), TYPE_ACTION_NAME ) self.id_action_url = sql.insert_log_action(type_url) self.id_action_name = sql.insert_log_action(type_name) self.exported = True def get_hash(self, value): return abs(hash(value)) class ActionManager(object): def __init__(self): """ self.actions will be path -> Action mapper """ self.actions = {} self.__counter = 0 def add_action(self, path, title): if path in self.actions: if not title in self.actions[path].titles: self.actions[path].titles.append(title) else: self.actions[path] = Action(path, title, self.counter_next()) def __getitem__(self, path): if path == None: return None if not path in self.actions: self.actions[path] = Action(path, None, self.counter_next()) return self.actions[path] def counter_next(self): self.__counter += 1 return self.__counter @property def toExport(self): """ Returns list of not yet exported actions""" return filter(lambda x: self.actions[x].exported == False, self.actions) def export(self, base_path): for action in self.toExport: self.actions[action].export(base_path) RE: 'X' object has no attribute 'y' - band_master - 04-23-2012 [quote='band_master' pid='278682' dateline='1335226686'] hi there, i am new to python. i installed it in order to run a script that migrates Google Analytics to Piwik, a locally hosted open source solution using MYSQL/PHP. Anyways, I was able to get python running with Google API and can run the script but I run into the following Python error: 'Action' object has no attribute 'id_action_url' Here is the code included in the file 'action.py' I had to upload this to google docs since the forum would not preserve the tab spacing which is oh so critical for python. here is the link: https://docs.google.com/document/d/1ScUulTmsUXi0PoFhAag27grzUZ3EJ071X1TxkP2P0qg/edit |