title: Python main function in class
body: <p>I'm new to python and the main() method and class def's are confusing me. I'm trying to create a bloom filter and my program keeps terminating because I don't think I'm calling things correctly.</p>
  <pre><code>    class BloomFilter(object):
          def __init__(self, numBits, numHashFunctions):
              self.numBits = numBits
              self.bitArray = [0] * numBits
              self.hash = bloomFilterHash(numBits, numHashFunctions)
  
          def insert(self, key):
  
          def lookup(self, key):
  
          def rand_inserts(self,num):
  
          def main(): #not sure if i should put this inside or outside class
              bloomfilter = BloomFilter(100,5)
              bloomfilter.rand_inserts(15)
  
      if __name__ == '__main__':   
          BloomFilter().main()
  </code></pre>
  <p>So if I wanted to create a bloom filter with 100 numBits and 5 hash functions, should i call that  under the <code>if __name__ == '__main__'</code> or under <code>def main()</code>? I'm not sure if I'm calling these correctly as I'm much more familiar with Java. thanks!</p>
  <pre><code>    def main():
          bloomfilter = BloomFilter(100,5)
          bloomfilter.rand_inserts(15)
  </code></pre>