class Solution: def __init__(self, data, filename='kumite776.txt', preopen=False): self.data = data self.filename = filename self.file = open(self.filename, 'w') if preopen else None def write_to_file(self): if not self.file: self.file = open(self.filename, 'w') self.file.write(self.data)
- class Solution:
- def __init__(self, data, filename='kumite776.txt', preopen=False):
- self.data = data
- self.filename = filename
if preopen:self.file = open(self.filename, 'w')else:self.file = None- self.file = open(self.filename, 'w') if preopen else None
- def write_to_file(self):
if not self.file:self.file = open(self.filename, 'w')- if not self.file: self.file = open(self.filename, 'w')
- self.file.write(self.data)