[newbie] How class works ?
Cliff Wells
logiplexsoftware at earthlink.net
Fri Jun 21 14:38:57 EDT 2002
On Fri, 21 Jun 2002 15:36:14 -0300
Marcus Vinicius Laranjeira wrote:
>
>
> I have a problem. I wrote a file with a class. When I try to instantiate
> this class in another file, I receive an error telling me : "Failed to
> reload - 'module' object is not callable
>
> I've tried many things to solve this problem, but I can't find where is the
> error or how to solve !
It would help us to help you if you posted some code so perhaps we could get an
idea of what you're doing wrong.
Anyway, here's a simple example of creating a class in file1.py and using it in
file2.py:
====== file1.py ========
class foo:
def __init__(self, arg):
self.arg = arg
def printit(self):
print self.arg
====== file2.py ========
import file1
f = file1.foo("Hello, world")
f.printit()
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list
mailing list