Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use factory pattern?
#1
I'm trying to understand and use factory pattern like:

class Factory():
  @staticmethod
  def getObj():
    return Drive()
    
class Drive():
  def select():
    print('select method from Drive class called')

obj = Factory.getObj()
obj.select()
But it throws an error:

Error:
TypeError: select() takes 0 positional arguments but 1 was given
Please help me understanding and using factory pattern.
Reply


Messages In This Thread
How to use factory pattern? - by bhojendra - Apr-29-2019, 01:52 PM
RE: How to use factory pattern? - by ichabod801 - Apr-29-2019, 01:55 PM
RE: How to use factory pattern? - by bhojendra - Apr-29-2019, 02:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Factory Design Pattern Prince 1 2,510 Apr-06-2018, 10:00 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020