GHpython Error: 'list' object has no attribute 'Angle'

Hello, everyone.
I get an error ''AttributeError: ‘list’ object has no attribute ‘Angle’ ‘’ in GH_python,wenn I use ‘‘Class’’ to define a Panel.



Could someone give me some advice?
Thanks!

Post the whole script! Line 59 where the error happens isn’t even shown in your screenshot!

Ok,I add the rest part now. But actually my code end at Line 58, from Line59 there are only the comments.
Thank you for your remind

Your class is called PanelGeo. On line 55, you instantiate a new list with a list comprehension that you also call “PanelGeo”, which - worst case scenario -, causes your class to be overwritten.
On line 58 inside your for loop, you attempt to call a class method, which isn’t possible without the instantiated object. Classes are blueprints for objects that “inherit” the blueprints functionality. You can thus only call class methods from an existing object.

Now, I’m not exactly sure what you are after, but here is how I would correct lines 55 to 59:

pg_list = [PanelGeo( PG_i_1[i], PG_i_2[i] ) for i in xrange(N)]

for i, pg in enumerate(pg_list):
    alpha = pg.Angle() # does not work because Angle() doesn't return anything
    print "Alpha_i_{} = {}".format(i+1, math.degrees(alpha)) # you need to import math

Another problem is that the Angle() method inside your class doesn’t return anything. alpha = pg.Angle() thus isn’t passed any value. You need to rename all self.alpha symbols to “alpha” and return this alpha at the end of the method.

If you want to keep self.alpha as a class attribute and update it with the Angle() method instead, you need to declare it in the class constructor (i.e self.alpha = None). In this case, your method doesn’t need to return anything. Instead you can change line 58 to angle = pg.angle.

I have found the Answer!
Anyway, Thank you so much