Python Class use

bruno at modulix onurb at xiludom.gro
Wed Feb 8 04:40:31 EST 2006


S Borg wrote:
>  Hello,
> 
>  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.
> 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, here is an example.
> 
> ########my saved file######
> class MyClass:
>   def f(self):
>       return 'calling f from MyClass'
> 
> #######interpreter#########
> 
>>>>x = MyClass()
>>>>(unhelpful error mesages)

This message - that is called a 'traceback' - may seem unhelpful to you,
but as a general rule, please post it : it may be *very* helpful to
those trying to help you (well, in this case the problem is pretty
obvious, but most of the time it is not...)

NB: see other answers in this thread about your actual problem - and
please take time to read the Fine Manual, specially:
http://docs.python.org/tut/node8.html


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list