<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">Hi,<br><br>I have a class called "vector". And I would like to define a function<br>
"dot" which would return a dot product of any two  "vectors". I want<br>to call this function as follow: dot(x,y).<br><br>Well, I can define a functions "dot" outside the class and it works<br>
exactly as I want. However, the problem is that this function is not<br>associated with the class (like methods a method of the class).<br><br>For example, if I call "x.calc()" or "y.calc()", python will execute<br>
different methods if "x" and "y" belongs to different classes. I want<br>to have the same with my "dot" function. I.e. I want it calculates the<br>dot product ONLY IF the both arguments of that function belong to the<br>
"vector" class.<br><br>Is it possible?<br><br>Thank you in advance.<br><br>Do you think a static method will do the thing?<br></blockquote><br>Well you can define the function inside the class.<br>Then create a name outside the class that references it. Is is.<br>
<br>dot = Class.dot.<br><br>By the way, why do you want to tie this function to the class?<br><br><br>-- <br>NOAGBODJI Paul Victor<br>