a program in python where I need to create a class and therefore invoke a method based on a dispatch function - basically a multimethod.In the OOP universe this looks an awful lot like a factory pattern; But now I'm stuck with this:
                  
                  
                  ```
                  
                  
                  ├── factory.py               ; class that creates the one I need
                  
                  
                  ├── website.py               ; an abstract interface 
                  
                  
                  └── websites                 ; children are implementations
                  
                  
                      ├── init.py              ; dumb python stuff lol
                  
                  
                      ├── website_1.py 
                  
                  
                      ├── website_2.py
                  
                  
                      ├── ...
                  
                  
                      └── website_n.py
                  
                  
                  ```
                  
                  
                  which looks like java (so, not exactly beautiful 😅 )
                  
                  
                  Is there any more "pythonic" way to do this?
                  
                  
                
Does factory need to be a class? Cant it be a function?
Обсуждают сегодня