Python Class use
Roy Smith
roy at panix.com
Tue Feb 7 15:34:39 EST 2006
S Borg <spwpreston at gmail.com> wrote:
> I am running Python on Mac OS X. The interpreter has been great for
> learning the basics, but I would now like to be able to reuse code.
Excellent. Code reuse is what it's all about!
> How do I write reusable code? I have done it "The Java way": write
> the class, and save it to my home directory, then call it from the
> interpreter
That's pretty much what you do in Python. Write your class into a
file called foo.py and save it. Then, start up an interpreter and do
"import foo". You might want to read about "modules" in the Python
tutorial (http://docs.python.org/tut/node8.html).
More information about the Python-list
mailing list