importing without executing the class - python

Viewed 4126

my problem is about i have a file that contain class and inside this class there is bunch of code will be executed

so whenever i import that file it will executed ! without creating an object of the class ! , here is the example

FILE X

class d:
    def __init__(self):
        print 'print this will NOT be printed'
    print "this will be printed"

file B

import x

output is this will be printed, so my question is how to skip executing it until creating a new object?

5 Answers
Related