I have the following classes in Python:
class String:
def clean_string(self, corpus):
f = open(corpus, 'r')
raw = f.read().lower()
f.close()
raw1 = re.sub(omissis, '', raw)
self.string = raw1
def print_string(self):
return self.string
class Set:
def letters_set(self, string):
self.let_set = set(re.findall(omissis, string))
class Dict:
def __init__(self, dictionary={}):
self.dictionary = {}
self.string = String()
self.let_set = Set()
def generate_possible_triplets(self, let_set):
triplet = [(ch1, ch2, ch3) for ch1 in let_set
for ch2 in let_set
for ch3 in let_set]
[...]
I have a problem with objects as function arguments. Suppose I want to create an instance of the class Set, one of class String and call the method .letters_set(String.string).
What do I have to put as argument inside the parenthesis? the name of the object of class string I will create? a variable referenced to this object? (same applies for the method .generate_possible_triplets in Dict. What form should let_set take?
letters_set()just expects a normal python string. Is that your intention or are you trying to integrate it with your customStringclass?foo = 0; func(foo)The need for this class has been largely supplanted by the ability to subclass directly from dict (a feature that became available starting with Python version 2.2).