Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does the order when defining functions in classes in python matter

When defining variables and functions within a class in python 3.x does it matter in which order you define variables and functions?

Is class code pre-complied before you would call the class in main?

like image 968
bpb101 Avatar asked Mar 14 '15 23:03

bpb101


1 Answers

By default, all names defined in the block of code right within the class statement become keys in a dict (that's passed to the metaclass to actually instantiate the class when said block is all done). In Python 3 you can change that (the metaclass can tell Python to use another mapping, such as an OrderedDict, if it needs to make definition order significant), but that's not the default.

like image 85
Alex Martelli Avatar answered Sep 30 '22 18:09

Alex Martelli