Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

Methods with the same name in one class in Python

$
0
0

How can I declare a few methods with the same name, but with different numbers of parameters or different types in one class?

What must I change in the following class?

class MyClass:""""""    #----------------------------------------------------------------------    def __init__(self):"""Constructor"""    def my_method(self,parameter_A_that_Must_Be_String):        print parameter_A_that_Must_Be_String    def my_method(self,parameter_A_that_Must_Be_String,parameter_B_that_Must_Be_String):        print parameter_A_that_Must_Be_String        print parameter_B_that_Must_Be_String    def my_method(self,parameter_A_that_Must_Be_String,parameter_A_that_Must_Be_Int):        print parameter_A_that_Must_Be_String * parameter_A_that_Must_Be_Int

Viewing all articles
Browse latest Browse all 23160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>