At that simple code, why python node does not return a list of numbers, Please have a look at the picture.
Iâve never created my own classes in python, but could that be the case? Youâre defining a new class and it seems to be returning the class object. My question would be âWhy does it need to be new class?â I realize this is probably a simplified example, but unless youâre using the class with another custom class it seems unnecessary.
Looking at this some more and Iâm guessing you may be new to Python (or at least IronPython) as your syntax is a little off. Besides not needing to define a class for a new function, Python would actually use return
instead of print
since there really is no print function. You also donât need to wrap your range in a list as itâs already considered one.
There is a print function in later releases It just goes to the Console, so is really only for debugging purposes.
Agreed with @Nick_Boyts - try replacing your print (number)
with return number
Thanks for reply , actually, Iâm posting that code only for testing, apparently, there are several bugs regarding classes in python nodes.
Unfortunately, return number
gives an error:
type error, init() should return none, not list
Youâre returning the class itself not the output. I havenât worked with classes much in dynamo, but I think you want to have some thing like âOUT = test1.Numberâ to get the class member
youâre returning your class, not a list - as @jpeele said above.
you should do
self.number = list blah blah blah
then OUT=test.number
to return the member.