Ulsa Minor Ulsa Minor - 9 months ago 34
Python Question

I have written two separate files, one containing classes and the other calling them but calling one makes object of all. Why?


class foo():
print 'a bunch of time consuming work'

class tryme():
print 'try me'*


from separate import *


It however printed both:

a bunch of time consuming work
try me


You should write an init for your classes then it wont happen anymore!

class foo():
  def __init__(self):
    print('a bunch of time consuming work')

class tryme():
  def __init__(self):
    print ('try me')