Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
single-instance class
#1
none of the argument/options parsers i have seen fit my needs. it appears i need to create my own. this is a case where i need only one instance. i would not be making multiple instances of it. i do not see a reason for this to be a class other than for the convenient reference naming which a module name can do anyway. what is the best way to construct this?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I still just use a class and create only one instance.
Recommended Tutorials:
Reply
#3
Same for me. It is a classical technique. It is related to the refactoring that Martin Fowler calls "Replace Function with Command". His arguments are the better flexibility of a class, the possibility of creating methods and fields to decompose a complex task, the possibility of inheritance, etc.
Reply
#4
i consider the module to be the created instance after it is imported. then it is like each function in that module is a method.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

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