(newbie) class with a single instance ?!

A

Andrea Tomadin

Hi,
I need a suggestion on the better implementation for a very basic task.

I run a program which does some logging on files. I want to collect
all the filenames and handlers in the same structure. All the files
should be opened at startup, closed at exit, and easily accessed by
the rest of the script.

I thought of writing a class with the file handlers as objects and
opening and closing operations within __init__ and __del__. Then an
instance of the class is created at the beginning of the program and
used.

This works, but isn't it weird to define a class if I know from the
very beginning that there will be no more than an instance of that
class?

Suggestions on this basic OOP task are very appreciated!
Thank you,

Andrea
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top