python - Declared list raises NoneType exception -


I have a snippet from someone else's Python module which is taking exception ( AttributeError: 'NoneType' object No specialty 'append' ). The snippet is:

  def generates stragames: tr = self.deviceTransform () if tr is none: returns pts = np.empty ((2, lane (self.data [' X ']))) Pts [0] = self.data [' x '] pts [1] = self.data [' y '] pts = fn.transform kordinate (tr, pts) self.fragments = [] pts = Np .clip (Points, -2 ** 30, 2 ** 30) ## Prevent QT Segmentation Fault ## However, however, will not be able to render properly. For Xrange (len (self.data)): rec = self.data [i] pos = qtcore.QPointF (number [0, ii], number [1, ii]) x, y, w, h = rec ['FragCoords'] rect = QtCore.QRectF (y, x, h, w) self.fragments.append (QtGui.QPainter.PixmapFragment.create (pos, rect))  

and The exception message is:

  [14:35:59] Ignored exception: | =============================> & gt; & Gt; | Traceback (most recent call final): | The file "/usr/lib/pymodules/python2.7/pyqtgraph/debug.py", in line 35, is w. Funk (* Args, ** KWDS). File "/usr/lib/pymodules/python2.7/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 714, in Paint | Self-engraved fregmings () | File "/usr/lib/pymodules/python2.7/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 685, in generates. Self.fragments.append (QtGui.QPainter.PixmapFragment.create (pos, rect)). AttributeError: There is no attribute 'append' in the 'NoneType' object. | ============================== & lt; & Lt;  

This is not the "Fix my error" question, but "how is it possible" is the question. A few lines above, self.fragments have been declared as empty lists. From that point on, the only modification of self.fragments is to call app () . How can the type change possibly? Is there a potential failure in append operation that NoneType ?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -