Yet another python question

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.

1 Like

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.

1 Like

There is a print function in later releases :smiley: 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


1 Like

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.


another solution

1 Like