logo-MindMajix
PostPythonPython
d
divija reddy

Posted on 25th July 2024|30 views

0
votes

Python Multiple Constructors

Can we define multiple constructors in python?

 I just want to know if is it possible to define various constructors, for example, assume there is a class called sales, and I would like to add somesales = sales() or somesales = sale("MAC") where first is defined give a default name value and second defines it.

 

1 answers
Answers
P
Surya kumar

Posted on 25th July 2024| views

try this

class Sales():

def_init_(self, sales=none):

pass

somesales = Sales(sales= “MAC”)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number